[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 470
  • Last Modified:

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?
0
nikinik
Asked:
nikinik
  • 6
  • 2
  • 2
1 Solution
 
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
 
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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:
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
 
ddayx10Commented:
lol "B" that's pretty critical considering....thanks all the same and you are welcome :)
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

  • 6
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now