• what’s wrong with this code??

    Home » Forums » Developers, developers, developers » Web design and development » what’s wrong with this code??

    Author
    Topic
    #408831

    Problem solved. Once again, it was a problem with the memo field data not getting pulled with the select statement. I had to remove the memo field from the query and call it explicitly. Sheesh!!

    I am trying to build an INSERT statement from a field collection in a SQL query. As you may know, apostrophes are field deliminators in SQL Server, so typically you wrap a field with replace(field, “‘”, “””) to escape the apostrophe. However, if the datasource for the field value is NULL you will get ‘invalid use of NULL’ when running replace.

    SO, I try this

    for each field in myRS

    if len(field) >0 then
    field = replace(field, “‘”, “””)
    end if

    ValueString = ValueString & “‘” & field & “‘, ”

    next

    and it STILL bombs with invalid use of NULL.

    ???

    And please don’t tell me not to have NULLS in the db — there’s several text boxes in the form and no reason to have a default value for them.

    any ideas?

    TIA brickwall

    Viewing 3 reply threads
    Author
    Replies
    • #866841

      We never used to have this problem with machine code…!

      John

    • #866842

      We never used to have this problem with machine code…!

      John

    • #867007

      “And please don’t tell me not to have NULLS in the db — there’s several text boxes in the form and no reason to have a default value for them.”

      I dunno. To me, having a problem with NULLS in the code sounds like a reason to have a default value for the text boxes. But I’m not telling you to eliminate the NULLS-maybe you have a better reason for having them than for not.

    • #867008

      “And please don’t tell me not to have NULLS in the db — there’s several text boxes in the form and no reason to have a default value for them.”

      I dunno. To me, having a problem with NULLS in the code sounds like a reason to have a default value for the text boxes. But I’m not telling you to eliminate the NULLS-maybe you have a better reason for having them than for not.

    Viewing 3 reply threads
    Reply To: what’s wrong with this code??

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: