SqlConnection conn; conn = new SqlConnection(); // conn.ConnectionString = "Data Source=Z-EDBBD13F6D384;Initial Catalog=student;User Id=sa;Password=123456"; conn.ConnectionString = "Data Source=192.168.1.108;Initial Catalog=student;User Id=sa;Password=123456"; conn.Open(); String sql = "select * from stutbl"; SqlCommand command = new SqlCommand(sql, conn); //建立 Command 对象 SqlDataReader reder = command.ExecuteReader(); while (reder.Read()) { //读出内容列 string str = reder["stu_name"].ToString(); //读取分类列 string str1 = reder["stu_pass"].ToString(); //分别为文本框加载数据 }