CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    INSERT nullstring INTO

    I execute an SQL statement "INSERT INTO ... VALUES ...", but if one of the values is null string ("") then SQL fails. What can I do for this?
    I am using VB6, ADO 2.7 and Access 2000.

  2. #2
    Join Date
    Jul 1999
    Location
    Athens, Hellas
    Posts
    769

    Re: INSERT nullstring INTO

    Resolved: I had a field with name DATE which conflicts with the DATE function of VB. I changed its name to BILLDATE and now it works no matter if there is null string or not.

  3. #3
    Join Date
    Jul 2004
    Location
    Jakarta, Indonesia
    Posts
    596

    Re: INSERT nullstring INTO

    Date is also a Reserved word in Access..u may want to consider change the field name or use [] bracket

    1st NF - a table should not contain repeating groups.
    2nd NF - any fields that do not depend fully on the primary key should be moved to another table.
    3rd NF - there should be no dependency between non key fields in same table.
    - E. Petroutsos -


    eRiCk

    A collection of "Laku-abis" Ebook, Permanent Residence

    Access Reserved Words, a Classic Form Bug, Access Limitation, Know run Process and the Lock they hold in, Logging User Activity in MSSQL

  4. #4
    Join Date
    Sep 2004
    Posts
    247

    Re: INSERT nullstring INTO

    Is there any reason you are inserting an empty string "" rather than NULL?

  5. #5
    Join Date
    Nov 2004
    Location
    Poland
    Posts
    1,355

    Re: INSERT nullstring INTO

    but if one of the values is null string ("") then SQL fails. What can I do for this?
    Generaly speaking this is a very bad idea to concatenate strings for executing SQL in ADO.I'm almost sure that U've done something like that: strSQL="INSERT INTO .... VALUES('" & strVar1 & "')".
    It leads to "SQL injection" problem (and also to a problem that U discover ).
    Proper (and safe) way to do it is to execute parametrized SQL in ADO.

    Best regards,
    Krzemo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured