con = new SqlConnection("server=PC;integrated security=SSPI;database=Friends");
sql = "SELECT * FROM [Users] where Login='{0}' and Password='{1}'";
// Format the string with the values provided
sql = string.Format(sql,txtLogin.Value,txtPwd.Value);
cmd = new SqlCommand(sql,con);
con.Open();
try
{
// Retrieve the UserID
id = (string)cmd.ExecuteScalar();
}
finally
{
con.Close();
}
integrated security=SSPI验证需要数据库Friends添加一个用户PC/ASPNET。我不太清楚为什么,哪位介绍一个数据库中各个用户权限以及编程中如何运用,例如:“data source=(local)\\**;initial catalog=Friends;user id=sa"这样的语句我始终无法访问数据库,sa用户如何添加呢?