vs2010 在服务器资源管理器里面已经连接好了数据库,但调试过程中ExecuteReader 当前状态为关闭。。特急
源代码:conn=newSqlConnection(Properties.Settings.Default.选课管理系统ConnectionString);conn.Op...
源代码:
conn = new SqlConnection(Properties.Settings.Default.选课管理系统ConnectionString);
conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlCommand cod = conn.CreateCommand();
if (radioButton1.Checked)
{
cmd.CommandText = "select * from student where sno='" + textBox1.Text + "'and spassword='" + textBox2.Text + "'";
SqlDataReader drr = cmd.ExecuteReader();
drr.Read();
if (drr.HasRows == false)
{
MessageBox.Show("密码或用户名有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
drr.Close();
textBox1.Text = "";
textBox2.Text = "";
return; 展开
conn = new SqlConnection(Properties.Settings.Default.选课管理系统ConnectionString);
conn.Open();
SqlCommand cmd = conn.CreateCommand();
SqlCommand cod = conn.CreateCommand();
if (radioButton1.Checked)
{
cmd.CommandText = "select * from student where sno='" + textBox1.Text + "'and spassword='" + textBox2.Text + "'";
SqlDataReader drr = cmd.ExecuteReader();
drr.Read();
if (drr.HasRows == false)
{
MessageBox.Show("密码或用户名有误,请重新输入", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
drr.Close();
textBox1.Text = "";
textBox2.Text = "";
return; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询