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