新手上路~今天做一个简单的登陆验证 如下
string name = textBox1.Text;
string password = textBox2.Text; string connstr = @"Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=mycomputer;Data Source=PC-05280902";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connstr;
string commstr = @"select * from login where name='" + textBox1.Text + "' and password='" + textBox2.Text+"' ";
SqlCommand comm = new SqlCommand();
comm.CommandText = commstr;
comm.Connection = conn; SqlDataAdapter da=new SqlDataAdapter();
da.SelectCommand=comm;
conn.Open();
DataSet ds = new DataSet();
da.Fill(ds);
int f = comm.ExecuteNonQuery(); if (f > 0)
MessageBox.Show("ok");
else
MessageBox.Show("no");
可是不管我输入正确or错误的信息都会弹出“no”
大侠们指点指点
string name = textBox1.Text;
string password = textBox2.Text; string connstr = @"Persist Security Info=False;User ID=sa;password=sa;Initial Catalog=mycomputer;Data Source=PC-05280902";
SqlConnection conn = new SqlConnection();
conn.ConnectionString = connstr;
string commstr = @"select * from login where name='" + textBox1.Text + "' and password='" + textBox2.Text+"' ";
SqlCommand comm = new SqlCommand();
comm.CommandText = commstr;
comm.Connection = conn; SqlDataAdapter da=new SqlDataAdapter();
da.SelectCommand=comm;
conn.Open();
DataSet ds = new DataSet();
da.Fill(ds);
int f = comm.ExecuteNonQuery(); if (f > 0)
MessageBox.Show("ok");
else
MessageBox.Show("no");
可是不管我输入正确or错误的信息都会弹出“no”
大侠们指点指点
解决方案 »
- c#问题
- c# 报表打印的时候每次都要选择打印机打印,能不能直接打呢?
- 对于事件委托的不解,望高手指导
- 如何捕捉反射的异常
- WinForm 之间交互操作
- 100分,来者有份,问题也很简单,快来啊
- 如何使用XPath,在一个有多个NameSpace的XmlDocument中,使用SelectNodes方法?(加分再提)
- 各位大哥请帮忙,字符串相关问题!急!
- 请教GetOleDbSchemaTable方法如何自增字段
- 调用ZLG600Lib.dl,报错尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
- c# *.csproj文件里的UseVSHostingProcess在VS2005的哪里设置?
- combobox能手动添加吗?
对select的返回始终都是-1,对update,delete,insert才是影响的行数呢
所以一直f都是-1,一直小于零,所以一直都是no