2

Question. I'm trying to use SQL to update a listview in C#. Using the Query Builder I can do a select, update, insert and delete. Ive got my select but I'm trying to get my update to work with no luck.( I want to use the update button on the listview to update the record) I need some insight as I think I'm writing it wrong. Thanks

 UPDATE       SF1411
 SET  ( ItemNumber, QuoteNumber, Item, Descp, Route, Unit, QTYOH, EXTQTY, CSTCD, 
      PCOST, SCOST, ACOST, TCOST, ICOST, Date, BIZCODE, DeleteItem)   
  =  SELECT [ItemNumber], [QuoteNumber], [Item], [Descp], [Route], [Unit], [QTYOH], 
     [EXTQTY], [CSTCD], [PCOST], [SCOST], [ACSOT], [TCOST], [ICOST], [Date], [BIZCODE],   
    [DeleteItem] 
    FROM [SF1411] WHERE ([QuoteNumber] = @QuoteNumber)
3
  • can use post a small C# sample code and the error that occurs? Commented Dec 29, 2010 at 13:14
  • What does MSSQL say when you execute this SQL directly? Commented Dec 29, 2010 at 13:19
  • could we see the C# and the error. Commented Dec 29, 2010 at 13:22

3 Answers 3

2

Im sorry if I understand you wrong, but shouldn't an update statement look like this..

UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Sign up to request clarification or add additional context in comments.

Comments

0

If I am correct your update command is wrong.

you need to tell value of each column rather than just fire a select command.

Comments

0

Just set individual values like below:

UPDATE SF1411
SET ItemNumber = SELECT [ItemNumber] FROM [SF1411] WHERE ([QuoteNumber] = @QuoteNumber);

Mostly this is used to update a specific value or if using select in set then it used to select from different table like:

Update table set column= "value" where condition;

or:

Update table set column = select column from tbl where condition;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.