Solved

Empty string to DBNull in Classic ASP

Posted on 2010-09-23
3
2,795 Views
Last Modified: 2012-05-10
I'm using classic ASP/VBScript and a SQL Server 2008 database.  I have  a text field that is optional. If a user leaves this field blank I want to sumbit a DBNull to my database.  How do I do this?

See attached Classic ASP/VBScrip code.




strEventAcronym = TRIM ( Request.Form( "eventAcronym" ) )



If strEventAcronym = "" Then

       strEventAcronym = ??? DBNULL ???

End If



' Perform INSERT

Open in new window

0
Comment
Question by:cdemott33
3 Comments
 
LVL 7

Expert Comment

by:waltersnowslinarnold
ID: 33746323
Dont pass any value from the front end, it automatically considers as NULL.
0
 

Author Comment

by:cdemott33
ID: 33746988
So how would I perform the Insert if there is not value?
0
 
LVL 3

Accepted Solution

by:
LouSch7 earned 500 total points
ID: 33747900
Here's the way I would do it.
strEventAcronym = TRIM ( Request.Form( "eventAcronym" ) )

If strEventAcronym = "" Then strEventAcronym = "NULL" End If

' Perform INSERT

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

863 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now