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();
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();
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();