Results 1 to 2 of 2

Thread: null error

  1. #1
    Join Date
    Feb 2002
    Posts
    60

    Unanswered: null error

    I'm using the following code to update a record:

    Code:
    '// Sub: Update Record
    Sub sEditRec
        Dim rst, i, strFieldName, strFieldValue
        Set rst = Server.CreateObject("ADODB.Recordset")
        rst.Open "SELECT * FROM tblNewBooks WHERE ID = " & Request.QueryString("edit"), conn, , 3
        For i=1 to rst.Fields.Count - 1
            Response.Write rst(i).Name
            strFieldName = rst(i).Name
            strFieldValue = Request.Form(strFieldName)
            If strFieldValue = "" Then
                rst(strFieldName) = "" '// ERRORS HERE
            Else
                rst(strFieldName) = strFieldValue
            End if
        Next
        rst.Update
        rst.Close
        Set rst = Nothing
    End Sub
    The problem arises when I try and enter a null string into a field. How do I handle this?
    Matt Alexander
    mattalexx@softhome.net

    Don't click here.

    Odigo: 5408962
    AIM: mattalexx
    ICQ: 138006220

  2. #2
    Join Date
    Feb 2002
    Location
    North Wales, UK
    Posts
    114
    A simply quick fix would be to store " " in the database field. I'm assuming that your getting an error when the value is null because the database field requires a value??
    J^ - web | email
    newsASP Developer

Posting Permissions

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