I tried using the below sqlcommand statement throwing error at where condition. What's wrong with the statement. Can any one help me please.
SqlCommand sqlcmd = new SqlCommand("insert into Database1(ProdcutReleaseDate) values('"+DateTime.Now+"') where [property address]='" + ComboBox1.SelectedValue+"'", sqlcon);
Thanks
sandeep
Nitin SontakkeRank #264 · 9.6K reputationPosted Jun 20, 2018, 5:54 AM EDT
Adeeb Arangodan24 reputationPosted Jun 19, 2018, 1:16 PM EDT
James AxsomRank #4,887 · 320 reputationPosted Jun 19, 2018, 4:45 PM EDT
Hi Sandeep,
If you would like to insert rows into a table via a filter, the INSERT INTO SELECT clause is available to you. Here’s how it works:
INSERT INTO
SELECT (Y.COL1, Y.COL2, Y.COL3)
FROM
WHERE Y.COL=@Value
Its great for copying data from one table to another. The main thing is that your columns share the same data type and relative size. Matching columns names are good but not required.
Columns (if any) not populated in the insert table get null values.
Hope this helps.
sandeep kumar67 reputationPosted Jun 20, 2018, 5:43 AM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts