读书人

C#登陆界面为什么小弟我就是读不出数

发布时间: 2013-08-01 15:23:18 作者: rapoo

C#登陆界面求助,为什么我就是读不出数据出来!!

private void button1_Click(object sender, EventArgs e)
{
String userid;

String userpassword;

userid = this.textBox1.Text;

userpassword = this.textBox2.Text;

if (userid == "" || userpassword == "")
{

MessageBox.Show("请确认您的输入!");

}
try
{
SqlConnection conn = new SqlConnection("server=.;database=Loading;Trusted_Connection=true");
SqlCommand cmd = new SqlCommand("select count(*) from Loa where 用户名='" + userid + "'and 密码='" + userpassword + "'", conn);
conn.Open();
int count = Convert.ToInt32(cmd.ExecuteScalar().ToString());
if (count>0)
{
main form = new main();
form.MdiParent = this;
form.Show();
this.Hide();
}


conn.Close();
}
catch(Exception ex)
{
MessageBox.Show("错误" + ex.ToString(), "错误");
}

}

[解决办法]
是什么错?发生异常吗?

读书人网 >C#

热点推荐