SqlDataReader dr= comm.ExecuteReader();错误 5
privatevoidbutton1_Click(objectsender,EventArgse){stringbitch="integratedSecurity=tru...
private void button1_Click(object sender, EventArgs e) { string bitch = " integrated Security=true;Initial Catalog=hui;Data Source=mic075"; SqlConnection conn = new SqlConnection(bitch); conn.Open(); if (textname.Text == "" || textpassword.Text == "") MessageBox.Show("信息不全,请不要遗漏信息!"); if (rbtnmanager.Checked) { string boss = "select * from dlb where 类别='管理员' and 用户名='" + textname.Text.Trim() + "'and 密码='" + textpassword.Text.Trim() + "'"; SqlCommand comm = new SqlCommand(boss, conn); SqlDataReader dr= comm.ExecuteReader();
怎么解决。。。 展开
怎么解决。。。 展开
3个回答
2015-07-10
展开全部
string connstr = "server=.;database=library;uid=sa;pwd=foolish;";
SqlConnection conn = new SqlConnection(connstr);
string sqlstr2 = "update book set 图书数量=图书数量-" + textBox5.Text + " where 图书编号=" + textBox4.Text;
string sqlstr = "update book2 set 借阅数量=借阅数量+" + textBox5.Text + " where 被借阅图书编号=" + textBox1.Text ;
SqlCommand comm=new SqlCommand(sqlstr,conn);
SqlCommand comm2 = new SqlCommand(sqlstr2, conn);
conn.Open();
SqlDataReader r = comm.ExecuteReader();
if (r.Read() == true)
{
MessageBox.Show("归还成功");
}
SqlConnection conn = new SqlConnection(connstr);
string sqlstr2 = "update book set 图书数量=图书数量-" + textBox5.Text + " where 图书编号=" + textBox4.Text;
string sqlstr = "update book2 set 借阅数量=借阅数量+" + textBox5.Text + " where 被借阅图书编号=" + textBox1.Text ;
SqlCommand comm=new SqlCommand(sqlstr,conn);
SqlCommand comm2 = new SqlCommand(sqlstr2, conn);
conn.Open();
SqlDataReader r = comm.ExecuteReader();
if (r.Read() == true)
{
MessageBox.Show("归还成功");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询