记得以前连接数据库都没问题,这次出啦问题,非常郁闷,高手帮我解决一下吧! 我贴下代码:
string connectionstring = "Data Source=PC-200801010000 \\SQLEXPRESS;Initial Catalog=financemanager;Integrated Security=True";
SqlConnection conn = new SqlConnection(connectionstring);
conn.open();
string sql = string.Format("select COUNT(*) from user where username='{0}' and password='{1}'", this.textBox1.Text.Trim(), this.textBox2.Text.Trim());
sqlcommand cmd=new sqlcommand(sql,conn);
int count = (int)cmd.ExecuteScalar();
conn.Close();
if (count>0)
{
MainForm mainform = new MainForm();
mainform.Show();
this.Hide(); }
else
{
label5.Visible = true;
textBox2.Text = "";
}上面是部分代码,不知道哪里错啦,语法是没错的啊,但是报错 --------》“关键字user附近有语法错误”。。
string connectionstring = "Data Source=PC-200801010000 \\SQLEXPRESS;Initial Catalog=financemanager;Integrated Security=True";
SqlConnection conn = new SqlConnection(connectionstring);
conn.open();
string sql = string.Format("select COUNT(*) from user where username='{0}' and password='{1}'", this.textBox1.Text.Trim(), this.textBox2.Text.Trim());
sqlcommand cmd=new sqlcommand(sql,conn);
int count = (int)cmd.ExecuteScalar();
conn.Close();
if (count>0)
{
MainForm mainform = new MainForm();
mainform.Show();
this.Hide(); }
else
{
label5.Visible = true;
textBox2.Text = "";
}上面是部分代码,不知道哪里错啦,语法是没错的啊,但是报错 --------》“关键字user附近有语法错误”。。
解决方案 »
- 新手请教 toolStripComboBox弹出listView控件
- 关于C# 调用C++写的动态库
- datagirdview通过列排序
- 关于sql事务处理
- 我来吐血一下,用了2周弄的一个C/S模式的桌面应用程序之后。。。
- 谁能编写一个利用session和数据库进行登录验证的网页?
- 有关提示框的
- WinForm:如何获得计算机当前进程中已启动的 iexplore.exe 进程对象的 URL 地址
- 怎么把2004-01-05转化为05Jan2004?
- .NET + DirectDraw 开发的程序在其他机器运行遇到System.IO.FileNotFoundException
- 有关Windows服务
- 关于窗口多次打开
把 user表 改成其他名字 试试
我是这样解决的 不知道为什么
单步调试语句看看