宿舍管理系统设计报告[1](10)
时间:2025-07-08
时间:2025-07-08
string num = "select * from Student_Table where 所住寝室='" this.room_Box.Text.Trim() + "'and 姓名='"+2_Box.Text.Trim()+"'"; SqlCommand cd = new SqlCommand(num, conn);
mandType = CommandType.Text; SqlDataReader dr=cd.ExecuteReader();
//string s = Convert.ToString(cd.ExecuteReader()); dr.Read();
if(!dr.HasRows) //此处验证所找人的姓名是否所在填写的寝室内 {
MessageBox.Show("请确定所访人员和寝室号是否有误"); } else {
conn.Close(); //先将上面用DataReader打开的数据库关闭
string insertSql = "insert into Com_Table values('" + this.num_Box.Text + "','"
+ 1_Box.Text + "','" + 2_Box.Text + "','" + this.room_Box.Text + "','"+this.time_Box.Text+"');";
SqlCommand cmd = new SqlCommand(insertSql, conn);
mandType = CommandType.Text;//sqlcommand用于向sql server发送sql语 conn.Open();
cmd.ExecuteNonQuery(); MessageBox.Show("登记完成");
}
修改用户信息如下
string sql = "server=jjaqq-pc;database=Dormitory;uid=sa;pwd=123456";
SqlConnection conn = new SqlConnection(sql); conn.Open(); try {
if(user_Box.Text.Trim()=="")
上一篇:专利检索与专利分析