C#登陆验证问题

zhimu 2006-12-19 10:06:25
string strconn = "server = (local);database = dongmu;Trusted_Connection=yes";
try
{
SqlConnection conn = new SqlConnection(strconn);
conn.Open();
string sql = "select * from user where name='"+this.textBox3.Text.Trim()+"'and pwd='"+this.textBox4.Text.Trim()+"'";
SqlDataAdapter da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
if (ds.Tables[0].Rows[0]["name"].ToString() == this.textBox3.Text.Trim())
{
form2 = new Form2();
form2.Visible = true;
}
conn.Close();
}
catch (Exception g)
{
MessageBox.Show(g.Message);
}


错误报告:user附近有语法错误,希望高手指点一下!
...全文
200 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
liujia_0421 2006-12-20
  • 打赏
  • 举报
回复
试试这个:
string sql = "select * from [user] where [name]='"+this.textBox3.Text.Trim()+"' and pwd='"+this.textBox4.Text.Trim()+"'";
zhimu 2006-12-20
  • 打赏
  • 举报
回复
谢谢!!
jrl5365 2006-12-20
  • 打赏
  • 举报
回复
[]
zottff 2006-12-19
  • 打赏
  • 举报
回复
将select * from user where name='"+this.textBox3.Text.Trim()+"'and pwd='"+this.textBox4.Text.Trim()+"'";形成真正的sql语句拷贝到查询分析器中执行一下就知道错误原因啦
srnpr 2006-12-19
  • 打赏
  • 举报
回复
user name 都是系统定义过的 最好这样写[user]

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧