开发者

error with constring in c# while connecting database

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)

The problem is the database property showing connection string data source as "xyz\sqlexpress" ..if i put the same connection string it wil show the error as "escape sequence used"(\)...if i modify connection string as only "xyz" then it wil give above given error...so please suggest me some s开发者_Python百科olution for this...

"i have allowed remote connection" and what is exactly this instance name?


You need to escape the backslash character:

If you construct the connection string in code:

"DataSource=xyz\\sqlexpress"

In your configuration file:

"DataSource=xyz\sqlexpress"


If your connection string contains a backslash ("\"), you need to double it up ("xyz\\sqlexpress") or escape it with @ (@"xyz\sqlexpress").

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜