string newsql = string.Format("update t_history set time = time, type = type, text = text, name = name, number = number");你上面这条语句没作用。你这里应该是INSRET INTO 语句。
解决方案 »
- 求助
- treeview 绑定数据,怎么实现这样的效果呢,大家帮忙看一下。
- c#高级编程中说堆栈中的内存高内存区是已用部分,低内存区是未用部分,还说得头头是道,可是小弟一测,为什么就截然相反啊,求教求教
- 我用C#做winfrom怎么能让一个窗口只弹出一次呀?(希望能有代码)
- 换个标题.大家都来吧.散分
- c#程序最多可使用多大的内存?
- 跪求[WinFrom]Listview分页显示程序的代码?
- 编译问题
- Gmail 新API 使用哪个接口进行回复邮件?
- “System.Data.OleDb.OleDbException”类型的未经处理的异常在 System.Data.dll 中发生 其他信息: 找不到文件
- float转换成string保留两位小数
- DataView只能保护行数据,不能保护列数据,是吗?
嗯,大神,我现在改成下面这样了。。你看下啊 string newsql = string.Format("insert into t_history (time,type,text,name,number )values(time,type,text,name,number)");
SqlCommand newcmd = new SqlCommand(newsql, sqlConnection);
SqlDataAdapter newdata = new SqlDataAdapter();
newdata.InsertCommand = newcmd;
newcmd.ExecuteNonQuery();//执行到此出错,错误如下图执行最后一句出现如下错误
嗯 谢谢。我现在改成如下: string newsql = string.Format("insert into t_history (time,type,text,name,number )values(time,type,text,name,number)");
SqlCommand newcmd = new SqlCommand(newsql, sqlConnection);
SqlDataAdapter newdata = new SqlDataAdapter();
newdata.InsertCommand = newcmd;
newcmd.ExecuteNonQuery();//执行到此出错。错误提示。在此上下文中不允许使用'time'。此处只允许使用常量、表达式或变量。不允许使用列名。
为什么啊
string newsql = string.Format("insert into t_history ([time],[type],[text],[name],[number]) values ('{0}','{1}','{2}','{3}','{4}')");
SqlCommand newcmd = new SqlCommand(newsql, sqlConnection);
SqlDataAdapter newdata = new SqlDataAdapter();
newdata.InsertCommand = newcmd;
newcmd.ExecuteNonQuery();