PDA

View Full Version : null error


mattalexx
04-13-02, 12:32
I'm using the following code to update a record:

'// 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?

JonathanB
04-14-02, 18:16
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??