Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > format empty as null prior to insert

Reply
Thread Tools

format empty as null prior to insert

 
 
David Shorthouse
Guest
Posts: n/a
 
      06-10-2005
Hey folks,

This one's probably been asked before but I'm tired of trying to find a
solution (if there is one!). I have an asp update page and I'd like to
convert all empty fields to NULL prior to updating the Access db rather than
permitting zero length fields in the db. Is this possible? Is there any way
to globally declare this for all text fields on the asp page rather than
having to do a whole whack of "if then" formats? Is there something I can
set in the field's properties in Access that will deny zero length yet won't
cause the asp update to choke and return an error?

Thanks for any feedback,

Dave

--
______________________________
Remove "_SPAM" to reply directly.


 
Reply With Quote
 
 
 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      06-10-2005
David Shorthouse wrote:
> Hey folks,
>
> This one's probably been asked before but I'm tired of trying to
> find a solution (if there is one!). I have an asp update page and I'd
> like to convert all empty fields to NULL prior to updating the Access
> db rather than permitting zero length fields in the db. Is this
> possible?


Sure, just pass Null when the user does not enter data.

> Is there any way to globally declare this for all text
> fields on the asp page rather than having to do a whole whack of "if
> then" formats?


No

> Is there something I can set in the field's properties
> in Access that will deny zero length yet won't cause the asp update
> to choke and return an error?


No.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
 
David Shorthouse
Guest
Posts: n/a
 
      06-10-2005
Bob,

Thanks for the quick response. How then does one pass null when the
field is empty? I'm sad to hear there isn't any way to declare this for all
variables in one shot, say at the very beginning of the script on the the
asp. Could you provide a vbscipt I ought to include on the asp?

Thanks.

Dave

--
______________________________
Remove "_SPAM" to reply directly.
"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> David Shorthouse wrote:
>> Hey folks,
>>
>> This one's probably been asked before but I'm tired of trying to
>> find a solution (if there is one!). I have an asp update page and I'd
>> like to convert all empty fields to NULL prior to updating the Access
>> db rather than permitting zero length fields in the db. Is this
>> possible?

>
> Sure, just pass Null when the user does not enter data.
>
>> Is there any way to globally declare this for all text
>> fields on the asp page rather than having to do a whole whack of "if
>> then" formats?

>
> No
>
>> Is there something I can set in the field's properties
>> in Access that will deny zero length yet won't cause the asp update
>> to choke and return an error?

>
> No.
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      06-10-2005
David Shorthouse wrote:
> Bob,
>
> Thanks for the quick response. How then does one pass null when the
> field is empty? I'm sad to hear there isn't any way to declare this
> for all variables in one shot, say at the very beginning of the
> script on the the asp. Could you provide a vbscipt I ought to include
> on the asp?


It depends. Are you using a recordset (not recommended)? Dynamic SQL (also
not recommended)? Parameters?
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
David Shorthouse
Guest
Posts: n/a
 
      06-10-2005
Bob,

I am indeed using a recordset with UPDATE and SET. Why is this not
recommended? What's the better alternative?

Dave

--
______________________________
Remove "_SPAM" to reply directly.
"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> David Shorthouse wrote:
>> Bob,
>>
>> Thanks for the quick response. How then does one pass null when the
>> field is empty? I'm sad to hear there isn't any way to declare this
>> for all variables in one shot, say at the very beginning of the
>> script on the the asp. Could you provide a vbscipt I ought to include
>> on the asp?

>
> It depends. Are you using a recordset (not recommended)? Dynamic SQL (also
> not recommended)? Parameters?
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      06-11-2005
David Shorthouse wrote:
> Bob,
>
> I am indeed using a recordset with UPDATE and SET. Why is this not
> recommended? What's the better alternative?
>


This is a contradiction. Using a recordset, you would open a recordset on a
table or select statement, point the cursor at a record, set the field
values and use the Update method to send the changes to the database. This
is not recommended because cursors are resource-intensive and slow. In ASP,
they should only be used to retrieve read-only data for display purposes.

Using "UPDATE and SET" seems to imply that you are using dynamic sql. This
is not recommended due to the security concerns brought on by leaving
yourself open to sql injection attacks by hackers:
http://mvp.unixwiz.net/techtips/sql-injection.html
http://www.sqlsecurity.com/DesktopDefault.aspx?tabid=23
http://www.nextgenss.com/papers/adva..._injection.pdf
http://www.nextgenss.com/papers/more..._injection.pdf


Perhaps you should read these:

http://www.google.com/groups?hl=en&l...TNGP12.phx.gbl

http://groups-beta.google.com/group/...e36562fee7804e


Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      06-13-2005
"Bob Barrows [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
: David Shorthouse wrote:
: > Bob,
: >
: > I am indeed using a recordset with UPDATE and SET. Why is this not
: > recommended? What's the better alternative?
<snip>
: Using "UPDATE and SET" seems to imply that you are using dynamic sql. This
: is not recommended due to the security concerns brought on by leaving
: yourself open to sql injection attacks by hackers:

I'd be happy to test those for ya', David. (O:=

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
howto: embed a text box in a footer of a GridView's boundfield columnto get data prior to a row insert dcollier9@cox.net ASP .Net 0 10-16-2008 03:31 PM
Begin() applied on empty Vector returns NULL or non null value???? Col C++ 1 04-21-2006 01:12 PM
"stringObj == null" vs "stringObj.equals(null)", for null check?? qazmlp1209@rediffmail.com Java 5 03-29-2006 10:37 PM
WinXP Initial Connection - Can it connect PRIOR to user login? =?Utf-8?B?RGFsZQ==?= Wireless Networking 2 07-15-2005 09:29 PM
interpreting a null pointer as an empty (null string) Dennis Allison C Programming 11 03-06-2004 12:47 PM



Advertisments