用C#做了个判断sql2005用户跟密码的登录程序,发现老是提示password列不存在
找到原因是在数据库,打开数据库一看依然提示:password列不存在
运行的T-SQL为:
SELECT * FROM school WHERE user='danny' AND password='123456'
school表里面也没有系统关键字的列名,求高手指导!

解决方案 »

  1.   

    SELECT * FROM school WHERE [user]='danny' AND [password]='123456'
      

  2.   

    不行! 提示user列跟password不存在
    主要是想判断用户名跟密码是否存在于数据库
      

  3.   

    你的school 表里有这两字段么?
      

  4.   

    没有啊,就是很奇怪
    CREATE TABLE [dbo].[school](
    [schoolid] [int] IDENTITY(1,1) NOT NULL,
    [studentname] [nchar](10) NULL,
    [old] [int] NULL,
    [address] [nchar](50) NULL,
    [job] [nchar](50) NULL,)
      

  5.   

    算了..算我没说你在和SQL开玩笑表内都没这字段  你的语句怎么可能成功?这是SQL最基本的语法
      

  6.   

    那应该如何用T-SQL判断用户名跟密码是否存在于SQL
      

  7.   

    建表时候漏加user和password字段了。
      

  8.   

    算了 我看各位大虾都不想答了 我说说吧 在school 里建两列 user和password 分别填上danny和123456
      

  9.   

    就是想用form做一个登陆SQL界面,好像是sqlcon出错了,请高手指点,要判断用户名跟密码是否存在于SQL
    string name = this.textBox1.Text.Trim();
    string password = this.textBox1.Text.Trim();
    string sqlcon = string.Format("select count(*) from school where '{0}'='danny' and '{1}'='123456'", name, password);
               
               string conn = "server=localhost;database=big1163;user=sa;password=shmily";
               SqlConnection cn = new SqlConnection(conn);
               SqlCommand cmd = new SqlCommand(sqlcon, cn);
               cn.Open();
               int a = (int)cmd.ExecuteScalar();
               
               if (a > 0)
               {
                   MessageBox.Show("数据接接成功! ");
                 
               }
              else
                   MessageBox.Show("数据库连接失败");
               cn.Close();
      

  10.   

    你查找的是school表里的东西,所以表里必须有你要的那些字段名字,在表里加上 user和password这两个字段,就OK啦