插入命令错误! [英] Insert command error !
问题描述
我正在研究实时项目的归档概念.
问题是,当我选中复选框时,应选择他的相应值,然后在提交"按钮上,单击事件应移至另一个名为s存档的页面.我的代码获取了几乎正确的值,但是当我需要复制查询的方法时,它显示了错误.
该值应在数据库中从一个表移至另一表,并在第二个表中应在archive.aspx页上的网格视图中显示内容.
当调用复制方法时,在填充数据表时将出现错误.
它给出了错误
,"附近的语法不正确."
据我了解,它在插入命令中有一个小错误,如下所示
Hi,
I am working on archiving concept of a live project.
The issue is that when i select check box he corresponding value should be selected and on the submit button click event should move to the another page named a s archive. My code is picking up almost correct values but when i need the method of copying the query is called it is showing error.
the value should move from one table to another in data-base and through the second table it should display the contents in grid view on the page archive.aspx.
the error is coming when data table is filled when copy method is called.
it gives a error
"Incorrect syntax near '',''."
as far as i understood its a small error in insert command which is as follows
string sql = "INSERT INTO tbl_Event(newsId,newsTitle,shortnews,newsDetails,postedDate,newsStatus)"
+ "SELECT (newsId,newsTitle,shortnews,newsDetails,postedDate,newsStatus)"
+ "FROM tbl_News where newsId = '"+newsId+"' ";
请帮忙.
问候,
Taresh
please help.
Regards,
Taresh
推荐答案
试试这个
Try this
string sql = "INSERT INTO tbl_Event(newsId,newsTitle,shortnews,newsDetails,postedDate,newsStatus)"
+ " SELECT newsId,newsTitle,shortnews,newsDetails,postedDate,newsStatus "
+ " FROM tbl_News where newsId = '"+newsId+"' ";
最后,它奏效了……取消了"+"号在哪里我将语句插入插入的下一行,我也删除了括号...所以它的工作..
thanx Rahul
问候,
Taresh
Finally it worked... iremoved the ''+'' sign where i ws breaking the statement into next line in insertion and i removed braces too...so its working..
thanx Rahul
Regards,
Taresh
这篇关于插入命令错误!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!