From Multiple connection strings i have to call SQL Server

Posted by Radhika10 under .NET Framework on 1/11/2018 | Points: 10 | Views : 2284 | Status : [Member] | Replies : 1
Hi Team,

In App.config file we have multiple connection strings from which we need to use SQLServer connection string.

<addname ="DB2" providerName="DB2" Connectionstring="">
<addname = "Oracle" providerName="Oracle" Connectionstring="">
<addname = "SQLServer" providerName="SQLServer" Connectionstring=""

Currently the application is hitting the Oracle DB to get the details and we need to interact with the SQL Server to get the details as part of the requirement.

What changes need to be done in the Connection string file that it should refer to the SQL Server?How to create a new class in the layer which will hit the SQL Server?

Thanks in Advance!!


Posted by: Sheonarayan on: 1/12/2018 [Administrator] HonoraryPlatinum | Points: 25

No need of any class. Simply change the connection string name to SQLServer and it should do the work.
Or change the ConnectionString value in the app.config file.

Of course, you will have to use SqlClient in place of OracleClient as name space (System.Data.SqlClient). The classes to connect to sql server are

SqlConnection in place of OracleConnection
SqlCommand in place of OracleCommand
SqlDataAdapter in place of OracleDataAdapter
SqlDataReader in place of OracleDataReader


Sheo Narayan

Radhika10, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response