Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass connection string that has a backward slash to SqlConnection?

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?

like image 424
user1104946 Avatar asked May 10 '12 21:05

user1104946


People also ask

What is SqlConnection string?

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.

What happens if SqlConnection is not closed?

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.

How do I declare SqlConnection?

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");


1 Answers

("Server=DB2\\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI");

or

(@"Server=DB2\XPT;DataBase=SCFHP_EDI_P1;Integrated Security=SSPI")
like image 162
Raphaël Althaus Avatar answered Sep 26 '22 14:09

Raphaël Althaus