C#编写小超市系统登陆界面~~!!!!!

[复制链接]
查看11 | 回复4 | 2009-12-18 12:23:59 | 显示全部楼层 |阅读模式
stringsqlcommand="select top 1 * from Loginwhere ID='"+UserCode +"'";
你这个查的是什么啊 ?找你数据库里存用户名的字段啊! '"+UserCode +"'";修改成这样试试stringsqlcommand="select top 1 * from Loginwhere ID="+UserCode ;
回复

使用道具 举报

千问 | 2009-12-18 12:23:59 | 显示全部楼层
缺cmd.Connection.close();我给你我做过的代码,你参考一下private void btn_login_Click(object sender, EventArgs e)
{
if (tb_name.Text.Trim() == "")
{
MessageBox.Show("请输入用户名!");
this.tb_name.Focus();
this.tb_name.SelectAll();
return;
}
if (tb_pwd.Text.Trim() == "")
{
MessageBox.Show("请输入密码!");
this.tb_pwd.Focus();
this.tb_pwd.SelectAll();
return;
}
string sql = "select user_id,user_pwd from 用户表 where user_id='"+tb_name.Text.Trim()+"' and user_pwd='"+tb_pwd.Text.Trim()+"'";
DataTable dt = db.myadapter(sql);
if (dt.Rows.Count > 0)
{
main f2 = new main();
this.Hide();
f2.ShowDialog();
this.Dispose();
}
else
{
MessageBox.Show("输入的用户名或密码错误!");
this.tb_name.Focus();
this.tb_name.SelectAll();
}}
回复

使用道具 举报

千问 | 2009-12-18 12:23:59 | 显示全部楼层
哥们 你最一下debug不就好了看一下变量运行到对比那一步 两个验证的值是否一样不就好了?何必现在和么麻烦的呢?
回复

使用道具 举报

千问 | 2009-12-18 12:23:59 | 显示全部楼层
Server=.;表示使用本机跟踪看usdr ["Password"].ToString ()=? UserPswd =?
回复

使用道具 举报

千问 | 2009-12-18 12:23:59 | 显示全部楼层
public static SqlConnection connStr = new SqlConnection(connstring); connStr.open();cmd. Connection=connStr;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行