列名称状态无效 [英] Invalid column name status

查看:71
本文介绍了列名称状态无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT Status UPDATE [Account] SET Status ='Accept'WHERERE Name = Name



状态存在于我的数据库中,所以这里有什么错误

SELECT Status UPDATE [Account] SET Status = 'Accept' WHERE Name = Name

Status exists in my db so what is wrong here

推荐答案

使用以下语句更新

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



如果您需要在更新后读取数据,请运行单独的声明


if you need to read the data after update, run separate statement

select Status from  [Account] WHERE Name = 'Name'


SELECT Status UPDATE [帐户] SET状态='接受'WHERE名称=姓名
名称应该是一个参数。


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 :) :) :)


这篇关于列名称状态无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆