If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > null error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-02, 11:32
mattalexx mattalexx is offline
Registered User
 
Join Date: Feb 2002
Posts: 60
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
Reply With Quote
  #2 (permalink)  
Old 04-14-02, 17:16
JonathanB JonathanB is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On