Solved

Empty string to DBNull in Classic ASP

Posted on 2010-09-23
3
2,867 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Executing a script on a timer online 5 32
Convert .csv to tab delimited text 11 49
I'm trying to understand this simple vb code! 2 37
Session on Html 8 36
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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