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 SontakkePosted Jun 20, 2018, 9:54 AM
sandeep kumarPosted Jun 20, 2018, 9:43 AM
James AxsomPosted Jun 19, 2018, 8:45 PM
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.
Adeeb ArangodanPosted Jun 19, 2018, 5:16 PM