I am trying to call the stored procedure using C#.
I am facing problem in the following line.
SqlConnection("Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");
The part that I am not able to use is the server DB2\XPT
.
What do I need to do to use server name as DB2\XPT
?
The connection string is an expression that contains the parameters required for the applications to connect a database server. In terms of SQL Server, connection strings include the server instance, database name, authentication details, and some other settings to communicate with the database server.
Not closing connections could cause timeouts as the connection pool may run out of available connections that can be used. A side point to this. If you use the using keyword, that will automatically close the connection for you.
A SqlConnection is an object, just like any other C# object. Most of the time, you just declare and instantiate the SqlConnection all at the same time, as shown below: SqlConnection conn = new SqlConnection( "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI");
("Server=DB2\\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");
or
(@"Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With