【这个写法哪里不对?】

flowerrain004 2005-02-01 10:55:49
OdbcCommand updatetz = new OdbcCommand("",MainForm.odbcConnect);

updatetz.CommandText = "update LZLJ_JH set LZLJ_JH_JHSL = '"+this.textBoxJHSL.Text+"',LZLJ_JH_TZSL = '"+this.textBoxTZSL.Text+"' where LZLJ_JH_KHBH = LZLJ_TZ_KHBH and LZLJ_JH_CPBH = LZLJ_TZ_CPBH and LZLJ_JH_XSBH = LZLJ_TZ_XSBH";

//以上为一行

updatetz.CommandType = CommandType.Text;
updatetz.Connection.Close();
updatetz.Connection.Open();
updatetz.ExecuteNonQuery();
...全文
99 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
jialiang 2005-02-01
  • 打赏
  • 举报
回复
错误?
CraxyMouse 2005-02-01
  • 打赏
  • 举报
回复
agree with:Eddie05(♂) 暴赱 『零零伍』 (︶﹏︶)
Eddie05 2005-02-01
  • 打赏
  • 举报
回复
updatetz.Connection.Close();
if(updatetz.Connection.State==ConnectionState.Closed)
updatetz.Connection.Open();
try
{
updatetz.ExecuteNonQuery();
}
catch
{
}
finally
{
updatetz.Connection.Close();

}
LoveCherry 2005-02-01
  • 打赏
  • 举报
回复
报错什么?
尽量避免字符串拼接,不安全又不整齐
liulxmooo 2005-02-01
  • 打赏
  • 举报
回复
up
morefish 2005-02-01
  • 打赏
  • 举报
回复
LZLJ_JH_KHBH = LZLJ_TZ_KHBH and LZLJ_JH_CPBH = LZLJ_TZ_CPBH and LZLJ_JH_XSBH = LZLJ_TZ_XSBH
update 的后面都有单引号,为什么where的后面没有单引号?( LZLJ_JH_KHBH = 'LZLJ_TZ_KHBH')
AllenTing 2005-02-01
  • 打赏
  • 举报
回复
最后还要关闭连接

110,499

社区成员

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

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

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