求解~~~C#连接Sql server 2005

作者在实现一个管理系统登录功能时遇到问题,尽管输入了正确的用户名和密码,但系统始终提示用户名错误。作者提供了相关代码片段,寻求解决之道。

现在在做一个作业,要做一个管理系统,可是第一步登录就进不去,很是着急,希望大家帮帮忙。我的App文件是这样写的

add key="Constr" value=" server=PC-201103212003/SQLEXPRESS;Initial Catalog =DrugShopMS;Integrated Security=SSPI;Connect Timeout=30;"/>

 

连接也没有提示有什么问题,可是输入登录框的用户名时,我输入的明明和数据库里的是一样的,可是缺总提示出错。

 

后面的代码是这样的

     private void button1_Click(object sender, EventArgs e)
        {
            if (textBox_yonghuming.Text.Trim() == "" || textBoxmima.Text.Trim() == "")
            {
                MessageBox.Show("用户名或密码不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string userID = textBox_yonghuming.Text.Trim();
            string userPassword = textBoxmima.Text.Trim();
            string type;
            string strSqlSelect = "SELECT * FROM manager_table where MID='" + userID + "'";
            DataSet ds = new DataSet();
            try
            {
                ds = DataSql.retSet(strSqlSelect);
             
                if (ds == null||ds.Tables[0].Rows.Count == 0)
                {
                     MessageBox.Show("用户名错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (!ds.Tables[0].Rows[0]["password"].ToString().Equals(userPassword))
                {
                    MessageBox.Show("密码错误!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

最后总会提示用户名错误,而且连接的特别的慢。求高人指点

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值