我的C# 在调用update的时候报错说 where附近有语法错误。高手帮我
来源:百度知道 编辑:UC知道 时间:2024/06/06 08:00:59
sbFriends.Groups[1].Items.Add(sbFriends.SeletedItem);
sbFriends.Groups[0].Items.Remove(sbFriends.SeletedItem); //循环判断出来
string sqla = string.Format("update friend set stranger={0},friendid={1} where hostid={2} and friendid={0}",id,null,Idinformation.id);
SqlCommand commandd = new SqlCommand(sqla, DBHelper.connection);
DBHelper.connection.Open();
int result = commandd.ExecuteNonQuery();
if (!(result < 1))
{
MessageBox.Show("添加成功");
}
DBHelper.connection.Close();
难道不能使用null?????? 如果是,那为什么拿到 数据库里面又可以呢 。郁闷啊。。帮忙啊。
sbFriends.Groups[0].Items.Remove(sbFriends.SeletedItem); //循环判断出来
string sqla = string.Format("update friend set stranger={0},friendid={1} where hostid={2} and friendid={0}",id,null,Idinformation.id);
SqlCommand commandd = new SqlCommand(sqla, DBHelper.connection);
DBHelper.connection.Open();
int result = commandd.ExecuteNonQuery();
if (!(result < 1))
{
MessageBox.Show("添加成功");
}
DBHelper.connection.Close();
难道不能使用null?????? 如果是,那为什么拿到 数据库里面又可以呢 。郁闷啊。。帮忙啊。
null那个改成双引号括起来的空""试试。
一定要更新为空吗?这个字段不进行更新行不行?
...C#中的NULL何数据库中的null是两回事,你不要混淆了。如果你想设置某个字段为null的话,可以像下面
string sqla = string.Format("update friend set stranger={0},friendid={1} where hostid={2} and friendid={0}",id,"null",Idinformation.id);
或者是
string sqla = string.Format("update friend set stranger={0},friendid=null where hostid={1} and friendid={0}",id,Idinformation.id);
肯定SQL语句有问题啊....语句呢?
`
PS:还在用ADO.NET的基础类库手动访问数据库吗?过时了....尝试下LINQ to Entity吧...
判断是否为空时应该使用 isnull 或 isnotnull (每个单词中间可能有空格,自己尝试),不能使用等号判断是否为空。
如果真的要空,一个是空串"",不过建意使用DBNull
C函数的调用!
开发c++MFC的时候如何调用lib文件
急!!!!!我的电脑中了一个来于在就电脑C:\Program files\common files\UPDATE\Update.exe
我做C程序的时候碰到一个函数调用的问题,懂的的人请进!
vc6编c的时候调用printf函数在调试时每次程序运行到printf函数行的时候,总会跳出对话框说找不到printf.c
在c++builder 中调用VC的DLL的问题
C语言 递归的调用
C语言的函数调用问题,请高手们指点我错在哪
我在迅雷下的 奇迹世界 选区的时候 显示update failed 就自动关闭了 高手指点一下
网页调用一个flash在每次调用的时候可以跳转到不同的帧吗???