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

    技术2022-05-18  14

    现在在做一个作业,要做一个管理系统,可是第一步登录就进不去,很是着急,希望大家帮帮忙。我的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;                }

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


    最新回复(0)