麻烦会的大神帮忙注释一下,新手不懂!!!!!
SqlConnection conn = new SqlConnection();//实例化对象
string conStr = @"Data Source=WHIZENDT016\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True";
conn.ConnectionString = conStr;
conn.Open();
SqlCommand cmd = new SqlCommand("select * from Users_id where Id='" + textBox1.Text + "'and Password ='" + textBox2.Text + "'", conn);
SqlDataReader str = cmd.ExecuteReader();
str.Read();
[解决办法]
- C# code
SqlConnection conn = new SqlConnection();//实例化对象 //接字符串 string conStr = @"Data Source=WHIZENDT016\SQLEXPRESS;Initial Catalog=Users;Integrated Security=True"; conn.ConnectionString = conStr; //打接 conn.Open(); //行sql 命令 SqlCommand cmd = new SqlCommand("select * from Users_id where Id='" + textBox1.Text + "'and Password ='" + textBox2.Text + "'", conn); //按READER方式行查 SqlDataReader str = cmd.ExecuteReader(); //此次可循READ,逐取得果 str.Read();