Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SELECT Status UPDATE [Account] SET Status = 'Accept' WHERE Name = Name

Status exists in my db so what is wrong here
Posted
Comments
[no name] 13-Jul-14 12:09pm    
http://www.codeproject.com/Questions/173387/Update-and-select-the-column-in-a-single-query-in

update with below Statement
SQL
UPDATE [Account] SET Status = 'Accept' WHERE Name = 'Name'

if you need to read the data after update, run separate statement
SQL
select Status from  [Account] WHERE Name = 'Name'
 
Share this answer
 
SELECT Status UPDATE [Account] SET Status = 'Accept' WHERE Name = Name
Name should be a parameter.
 
Share this answer
 
Comments
polkj 14-Jul-14 3:09am    
But Status given an error, and i doing a cmd. executeNonquery
error is because you have not mention to select status where to pick,

if you want update and get record first update than get as here
 
SqlConnection con = new SqlConnection(@"data source=My\SQLEXPRESS;initial catalog=Test;integrated security=True;");
                con.Open();
                SqlCommand cmd = new SqlCommand("update FIFAWorldCup set WinningCountryName='Germany' where CountryID=7 select   WinningCountryName from FIFAWorldCup", con);
                // SqlDataAdapter da = new SqlDataAdapter(cmd);
                // DataSet ds=new DataSet();
                //  da.Fill(ds);
                cmd.ExecuteNonQuery();

but if you are selecting table than use dataset insted of    cmd.ExecuteNonQuery();

happy coding cheeerrrssss :) :) :)
 
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