Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从数据库中删除列数据_C#_Asp.net_Sql Server - Fatal编程技术网

C# 从数据库中删除列数据

C# 从数据库中删除列数据,c#,asp.net,sql-server,C#,Asp.net,Sql Server,在我的数据库中,我有用户名、密码、地址、城市……等等。 使用此代码可以从数据库中删除整行: SqlCommand cmd = new SqlCommand("Delete from customer_registration where username='"+ Session["username"] +"'",del); 我的数据库包含以下数据: 如何删除某些列数据,或将其设置回NULL? 你可以像那样更新你的记录 更新您的_表 将某些列设置为NULL 其中id=123 您可以这样更新记录

在我的数据库中,我有用户名、密码、地址、城市……等等。 使用此代码可以从数据库中删除整行:

SqlCommand cmd = new SqlCommand("Delete from customer_registration where username='"+ Session["username"] +"'",del);
我的数据库包含以下数据:

如何删除某些列数据,或将其设置回NULL?
你可以像那样更新你的记录

更新您的_表
将某些列设置为NULL
其中id=123

您可以这样更新记录

更新您的_表
将某些列设置为NULL
其中id=123

是否有数字主键列?或者用户名是你的主键字段吗?你应该用它来代替你当前的方法…你有一个数字主键列吗?或者用户名是您的主键字段吗?您应该使用,而不是当前的方法。。。。