Set value of SQL DB field back to NULL using ASP

Once a field in a DB already has a value, can it be set back to NULL using ASP?
nikinikAsked:
Who is Participating?
 
ddayx10Connect With a Mentor Commented:
ooo I botched the uStatement... where is my head today?

Here's another example:
Dim uStatement as string =  "UPDATE tbl SET tblColumn =" & DBNull.Value & "WHERE tblColumn2 = 1"
Dim conn as New SqlDataConnection([ConnectionStringGoesHERE])
Dim cmd as New SqlCommand(uStatement,Conn)
0
 
cdaly33Commented:
Yes, the specifics depend on what type of data access you're using.
0
 
nikinikAuthor Commented:
I don't understand your question.  I'm accessing a SQLServer 2005 DB via ASP.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ddayx10Commented:
It used to be that in Enterprise Manager/Sql Server Managerment Studio if you were selected on the field that you wanted set to null and pressed Ctrl-0 and then leave the field. I havent tried it in a long time.

If you are trying to set it programatically using .net or something then it depends on what language you are using as to how to accomplish this.

dday
0
 
ddayx10Commented:
Ok so I was curious if it still worked...it does :)
0
 
cdaly33Commented:
Are you using a ADO or a custom provider?  Are you accessing stored procedures or doing direct updates to the data?
0
 
ddayx10Commented:
Sorry to stretch these out...little quirky today I guess.

Ex of how to set null value programatically (one of many ways depending on how accessing db):
VB: Dim p As SqlParameter = New SqlParameter("@p", DBNull.Value)

C#: sqlParameter p = new sqlParameter("@p",DBNull.Value);

dday
0
 
nikinikAuthor Commented:
As stated in the original question...I'm trying to do it programatically in ASP.
0
 
ddayx10Commented:
I understand that, but you didnt see what language you were using in ASP (C#, VB, etc) and you didnt give any context so I had a little fun and showed you both programmatically (see posts above), and using the database management tools.

If you would like a more specific example of how to set the value to null it would be necessary to see the context of the code you are trying to use.

Here's another example:
Dim uStatement as string =  "DBNull.Value & WHERE tblColumn2 = 1"
Dim conn as New SqlDataConnection([ConnectionStringGoesHERE])
Dim cmd as New SqlCommand(uStatement,Conn)

later....

dday

0
 
ddayx10Commented:
lol "B" that's pretty critical considering....thanks all the same and you are welcome :)
0
All Courses

From novice to tech pro — start learning today.