请.NET高手帮忙看看

来源:百度知道 编辑:UC知道 时间:2024/09/28 14:01:58
我写了段登陆代码 总是有错 提示说SHOW没有定义 我也不知道怎么改 顺便帮满看看代码有错没 谢谢
protected void Button1_Click(object sender, EventArgs e)

{

string strConn = ("Server=; Database=itzc; uid=sa;pwd=sa;");
string strCmd = ("select count(*) from Staff_login where (S_ID == ' " + S_ID.Text + " ' and Sl_pwd= ' " + Sl_pwd.Text + " '");
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = strConn;
SqlCommand myCommand = new SqlCommand(strCmd, myConnection);
myCommand.Connection.Open();
int flag = System.Convert.ToInt32(myCommand.ExecuteScalar());
myCommand.Connection.Close();
myConnection.Close();

if (S_ID.Text == " ")
{
S_ID.Text.Show("用户名不能为空 ");
}
else if (Sl_pwd.Text == " ")

你这是winform还是web的,我想你的是textBox..只是show一个值.如果是winform的话,你要用Message.Show("");web的话,,,就是Response.Write("");

题外话:
1 你这种错误在编译时就能发现 你还去运行?
2 你对控件不是很熟悉 建议多看看控件

protected void Button1_Click(object sender, EventArgs e)

{

string strConn = ("Server=; Database=itzc; uid=sa;pwd=sa;");
string strCmd = ("select count(*) from Staff_login where (S_ID == ' " + S_ID.Text + " ' and Sl_pwd= ' " + Sl_pwd.Text + " '");
SqlConnection myConnection = new SqlConnection();
myConnection.ConnectionString = strConn;
SqlCommand myCommand = new SqlCommand(strCmd, myConnection);
myCommand.Connection.Open();
int flag = System.Convert.ToInt32(myCommand.ExecuteScalar());
myCommand.Connection.Close();
myConnection.Close();
if (S_ID.Text == " ")
{
Response.Redirect("用户名不能为空 ");
}
else if (Sl_pwd.Text