Solved

Empty string to DBNull in Classic ASP

Posted on 2010-09-23
3
2,766 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
Comment Utility
Dont pass any value from the front end, it automatically considers as NULL.
0
 

Author Comment

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

Accepted Solution

by:
LouSch7 earned 500 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

6 Experts available now in Live!

Get 1:1 Help Now