Click here to Skip to main content
15,922,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
SQL
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+"' ";


please help.

Regards,
Taresh
Posted
Updated 10-Feb-12 19:15pm
v2

Try this

SQL
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+"' ";
 
Share this answer
 
Comments
Taresh Uppal 11-Feb-12 2:48am    
I have done this but using this it shows a new error which says
Invalid column name 'newsId'.
Invalid column name 'newsId'.
Invalid column name 'newsTitle'.
Invalid column name 'shortnews'.
Invalid column name 'newsDetails'.
Invalid column name 'postedDate'.
Invalid column name 'newsStatusFROM'.
RDBurmon 11-Feb-12 5:44am    
Please copy and paste as it is
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+"' ";


Also share you table stucture of tbl_News and tbl_Event
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900