If you are marking the connection string with @ to make it a literal you should only use one backslash in the data source
DataSource=.\SQLEXPRESS
string m_connectionString = string.Format(@"Data Source=.\SQLEXPRESS; User ID=sa; Password=~password1234");
using (SqlConnection con=new SqlConnection(m_connectionString))
{
using (SqlCommand cmd = con.CreateCommand())
{
cmd.CommandText = "select * from s.dbo.T_Users where UserName=@UserName";
}
}
有用链接
http://www.youtube.com/watch?v=aU8RhjdkCoE
(2)NOTE:
|
If you are marking the connection string with @ to make it a literal you should only use one backslash in the data source
|
7
|
If you are marking the connection string with @ to make it a literal you should only use one backslash in the data source
|