VS C# 使用UPTATE 时出错了。请高手帮忙看一下哪里出问题拉
来源:百度知道 编辑:UC知道 时间:2024/05/24 18:19:46
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();
提示说 关键值 where附近有语法错误。。我郁闷了 难道不能用 null
如果是 那应该怎么 设置数据为 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();
提示说 关键值 where附近有语法错误。。我郁闷了 难道不能用 null
如果是 那应该怎么 设置数据为 null呢 ?
改成下面的,加引号当成字符串传进去
string sqla = string.Format("update friend set stranger={0},friendid={1} where hostid={2} and friendid={0}",id,"null",Idinformation.id);
你上面的sql语句将生成类似下面的语句
update friend set stranger=1,friendid= where hostid=2 and friendid=1
是不是有明显的错误,你可以调试看看
一楼 二楼都正解 看来我又只能混分了
其实null可以直接写 ''
盗版XP 怎么使用Windows Uptate 升级啊
c盘出错了!
C编译时出错
使用EasyRecovery恢复格式化的分区时,出错了,求救。
开机提示加载错误C:\windows\system32\weabek85.dll错误时出错 另一个程序在使用它 请帮帮小弟 拜托了
加载c:window/system32/qmlqd258.dll时出错另一个程序正在使用此文件
加载 C:\WINDOWS\system32\ldwefd44.dll时出错,另一个程序正在使用
使用Excel复制时出错
在VS.NET2003中创建水晶报表控件时出错
装VS.NET2005时.NET_Framework2.0总是安装出错怎么回事?