日期:2014-05-18 浏览次数:21035 次
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();