Solved

Set value of SQL DB field back to NULL using ASP

Posted on 2009-05-15
10
466 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

729 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