Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
We have column list,From table Name,where conditions Informaion.Using this info we want DB query in .net which will used for all database like SQL,Oracle.

Column List - A,B,C
From Table - D
Where condiiotn- A='a'

What I have tried:

I have not got a perfect solutions .All the query builders required database Information like username password .So i m not interested to provides all the DB data.
Posted
Updated 15-Jan-18 20:52pm

1 solution

The query is simple:
SQL
SELECT A, B, C FROM D WHERE A = 'a';

But the "required database Information like username password .So i m not interested to provides all the DB data." is necessary.
You can't just access a database of any type randomly: you need to tell the system which database engine to use (by using the correct set of classes: SqlConnection, SqlCommand, ... for SQL Server, MySqlConnection, MySqlCommand, ... for MySql, OleDbConnection, OleDbCommand, ... for ODBC sources like Access, Excel, ..., OracleConnection, OracleCommand, ... for Oracle.
And y-u need to provide the XXXConnection object instance with a Connection String to tell it which server (if appropriate) and which database on the server you need to access. And to prevent people who shouldn't have access to your data getting in, that connection string will probably need user name and password (for live systems, development get by with Window Authentication).

You can't get away from that, and more than you can get away from the need to have your car car with you in order to drive to the shops: it's the "connection string" that lets you drive a specific vehicle. A different "connection string" in the form of a different key is needed to drive my car.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900