Solved

Set value of SQL DB field back to NULL using ASP

Posted on 2009-05-15
10
465 Views
Last Modified: 2012-05-07
Once a field in a DB already has a value, can it be set back to NULL using ASP?
0
Comment
Question by:nikinik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
10 Comments
 
LVL 9

Expert Comment

by:cdaly33
ID: 24399141
Yes, the specifics depend on what type of data access you're using.
0
 

Author Comment

by:nikinik
ID: 24399193
I don't understand your question.  I'm accessing a SQLServer 2005 DB via ASP.
0
 
LVL 20

Expert Comment

by:ddayx10
ID: 24399240
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 20

Expert Comment

by:ddayx10
ID: 24399256
Ok so I was curious if it still worked...it does :)
0
 
LVL 9

Expert Comment

by:cdaly33
ID: 24399265
Are you using a ADO or a custom provider?  Are you accessing stored procedures or doing direct updates to the data?
0
 
LVL 20

Expert Comment

by:ddayx10
ID: 24399299
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
 

Author Comment

by:nikinik
ID: 24399371
As stated in the original question...I'm trying to do it programatically in ASP.
0
 
LVL 20

Expert Comment

by:ddayx10
ID: 24399447
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
 
LVL 20

Accepted Solution

by:
ddayx10 earned 500 total points
ID: 24399470
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
 
LVL 20

Expert Comment

by:ddayx10
ID: 24399520
lol "B" that's pretty critical considering....thanks all the same and you are welcome :)
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weighted Randomizing 6 33
How can I use this function? 3 33
Html split(text) 2 31
Change this SQL to get all nodes 3 40
I've encountered valid database schemas that do not have a primary key.  For example, I use LogParser from Microsoft to push IIS logs into a SQL database table for processing and analysis.  However, occasionally due to user error or a scheduled task…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question