format empty as null prior to insert

Discussion in 'ASP General' started by David Shorthouse, Jun 10, 2005.

  1. 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.
     
    David Shorthouse, Jun 10, 2005
    #1
    1. Advertisements

  2. 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"
     
    Bob Barrows [MVP], Jun 10, 2005
    #2
    1. Advertisements

  3. 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]" <> wrote in message
    news:%...
    > 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"
    >
     
    David Shorthouse, Jun 10, 2005
    #3
  4. 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"
     
    Bob Barrows [MVP], Jun 10, 2005
    #4
  5. 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]" <> wrote in message
    news:...
    > 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"
    >
     
    David Shorthouse, Jun 10, 2005
    #5
  6. 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/advanced_sql_injection.pdf
    http://www.nextgenss.com/papers/more_advanced_sql_injection.pdf


    Perhaps you should read these:

    http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=

    http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e


    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"
     
    Bob Barrows [MVP], Jun 11, 2005
    #6
  7. David Shorthouse

    Roland Hall Guest

    "Bob Barrows [MVP]" <> wrote in message
    news:...
    : 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
     
    Roland Hall, Jun 13, 2005
    #7
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    30,346
    Mike Schilling
    Mar 29, 2006
  2. John

    empty/non-empty element

    John, Jul 15, 2003, in forum: XML
    Replies:
    1
    Views:
    1,317
    Klaus Johannes Rusch
    Jul 16, 2003
  3. Lukas
    Replies:
    3
    Views:
    1,070
    spiff
    Nov 10, 2005
  4. Marcia Hon

    Check if a directory is empty and empty it

    Marcia Hon, Feb 8, 2004, in forum: C Programming
    Replies:
    8
    Views:
    892
    Dave Thompson
    Feb 14, 2004
  5. Dennis Allison

    interpreting a null pointer as an empty (null string)

    Dennis Allison, Mar 5, 2004, in forum: C Programming
    Replies:
    11
    Views:
    1,033
    Derk Gwen
    Mar 6, 2004
  6. Brian Roberts

    empty lists vs empty generators

    Brian Roberts, May 3, 2005, in forum: Python
    Replies:
    12
    Views:
    911
    Jeremy Bowers
    May 4, 2005
  7. ButlerDJIAM
    Replies:
    0
    Views:
    712
    ButlerDJIAM
    Nov 9, 2006
  8. Col
    Replies:
    1
    Views:
    833
    peter koch
    Apr 21, 2006
Loading...