在线等啊

wk836119465 2013-06-11 12:49:54
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection();
conn.ConnectionString = "Data Source=(local);Initial Catalog=team11;Integrated Security=True";
conn.Open();
string sql = "select * from C_Select where order='" + textBox1.Text + "'";
SqlCommand sqlCommand = new SqlCommand(sql, conn);
SqlDataReader reader = sqlCommand.ExecuteReader();这里哪里错了啊
if (reader != null)
{
if (!reader.Read())
{
MessageBox.Show("输入序号错误,请重新输入");
return;
}
}
}
...全文
532 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
u011041372 2013-06-12
  • 打赏
  • 举报
回复
好深奥啊2123123123
siaswj 2013-06-12
  • 打赏
  • 举报
回复
是的,你等,我看
EnForGrass 2013-06-11
  • 打赏
  • 举报
回复
报什么错??检查一下,连接字符串有没有问题
inlcude_cx 2013-06-11
  • 打赏
  • 举报
回复
在线等,我也等
ganshenml 2013-06-11
  • 打赏
  • 举报
回复
conn.Open(); 写在 SqlCommand sqlCommand = new SqlCommand(sql, conn);后面 ;还有楼主没有关闭连接!
auos 2013-06-11
  • 打赏
  • 举报
回复
的确,order不能用 ,同样,千万别用,name,password什么的当字段名。
wk836119465 2013-06-11
  • 打赏
  • 举报
回复
order 好像是数据库里面的关键字 所以出错了
yanghailun_ 2013-06-11
  • 打赏
  • 举报
回复
1 调试在conn.Open();看看连接是否正常。 2 在 SQL Server Management Studio ,看看你要查询的语句是否能得到正确的期望结果: string sql = "select * from C_Select where order='" + textBox1.Text + "'"; 3 贴出出错信息,这样大家才能清晰知道问题点...

110,571

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧