标题:用户登陆代码问题
取消只看楼主
kitesky230
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2007-3-22
 问题点数:0 回复次数:1 
用户登陆代码问题

try
{
string myconn="Integrated Security=SSPI;User Id=sa;database=jindu2;server=localhost";
SqlConnection myconnection=new SqlConnection (myconn);
myconnection.Open();//打开数据库连接
string usname="select * from userinfo where username="+textBox1.Text +" and password="+textBox2.Text +"";
SqlCommand cmdd = new SqlCommand(usname, myconnection);
SqlDataReader myreader=cmdd.ExecuteReader();
if(myreader.Read ())
{
Form1 form1=new Form1 ();
form1.Show ();
this.Dispose ();
}
else
MessageBox.Show ("你输入的密码不正确,请重新输入");
myreader.Close ();
myconnection.Close ();
}

catch(Exception ex)
{
MessageBox.Show (ex.ToString());
}

输入用户名和密码总是提示列名无效,比如用户名li,密码123,则提示列名'li'无效,列名'123'无效

搜索更多相关主题的帖子: 代码 用户 登陆 
2007-04-18 21:27
kitesky230
Rank: 1
等 级:新手上路
帖 子:16
专家分:0
注 册:2007-3-22
得分:0 
错误在哪,请高手指教

2007-04-18 21:29



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-132986-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.294055 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved