每次运行代码时我都会遇到问题..这是我的代码:
SqlConnection con = new SqlConnection("DataSource=SQLSERVER;Bar_login; Integrated Security = True");
DataTable dt = new DataTable();
SqlDataAdapter sda = new SqlDataAdapter("select * from Bar_login where username = '" + txtuser.Text + "' and password ='" + txtpass.Text + "' ", con);
sda.Fill(dt);
if (dt.Rows.Count == 1)
{
MessageBox.Show("Login Succesfully");
}
else
{
MessageBox.Show("Wrong Username and Password");
}
它成功运行,但在登录过程之后..出现异常
unhandled.."System.ArgumentException: 'Keyword not supported: 'datasource'.'".
有人可以帮忙吗?
最佳答案
连接字符串中的“Data”和“Source”之间应该有一个空格。关键字是“Data Source”而不是“DataSource”。
关于c# - 系统参数异常 : 'Keyword not supported: ' datasource'. ',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51907495/