Forums

ASP

This topic is locked

Record Insertion;null value error...huh?help pls!

Posted 25 Sep 2005 12:13:50
1
has voted
25 Sep 2005 12:13:50 Keji Adedeji posted:
Hi All....again...really at a loss here,

I am trying to create a record insert page which then directs the user to a page displaying the inserted record.I keep encountering this error message:

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] You tried to assign the Null value to a variable that is not a Variant data type.
/COPSNet/TMP1ij8jnd6i2.asp, line 116

Line 116 in my code is:
MM_editCmd.Execute

I am still very new to all of this and an explanation of what this means and any help will be appreciated. please see some of the page code below

' create the sql insert statement
MM_tableValues = ""
MM_dbValues = ""
For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
MM_formVal = MM_fields(MM_i+1)
MM_typeArray = Split(MM_columns(MM_i+1),","
MM_delim = MM_typeArray(0)
If (MM_delim = "none" Then MM_delim = ""
MM_altVal = MM_typeArray(1)
If (MM_altVal = "none" Then MM_altVal = ""
MM_emptyVal = MM_typeArray(2)
If (MM_emptyVal = "none" Then MM_emptyVal = ""
If (MM_formVal = "" Then
MM_formVal = MM_emptyVal
Else
If (MM_altVal <> "" Then
MM_formVal = MM_altVal
ElseIf (MM_delim = "'" Then ' escape quotes
MM_formVal = "'" & Replace(MM_formVal,"'","''" & "'"
Else
MM_formVal = MM_delim + MM_formVal + MM_delim
End If
End If
If (MM_i <> LBound(MM_fields)) Then
MM_tableValues = MM_tableValues & ","
MM_dbValues = MM_dbValues & ","
End If
MM_tableValues = MM_tableValues & MM_columns(MM_i)
MM_dbValues = MM_dbValues & MM_formVal
Next
MM_editQuery = "insert into " & MM_editTable & " (" & MM_tableValues & " values (" & MM_dbValues & ""

If (Not MM_abortEdit) Then
' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command"
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = MM_editQuery
MM_editCmd.Execute
MM_editCmd.ActiveConnection.Close

If (MM_editRedirectUrl <> "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%>
<%
Dim rsCustType
Dim rsCustType_numRows

Set rsCustType = Server.CreateObject("ADODB.Recordset"
rsCustType.ActiveConnection = MM_COPS_STRING
rsCustType.Source = "SELECT * FROM CustomerType ORDER BY TypeCode ASC"
rsCustType.CursorType = 0
rsCustType.CursorLocation = 2
rsCustType.LockType = 1
rsCustType.Open()

rsCustType_numRows = 0
%>
<%
Dim rsContact
Dim rsContact_numRows

Set rsContact = Server.CreateObject("ADODB.Recordset"
rsContact.ActiveConnection = MM_COPS_STRING
rsContact.Source = "SELECT * FROM Contact ORDER BY ContactCode ASC"
rsContact.CursorType = 0
rsContact.CursorLocation = 2
rsContact.LockType = 1
rsContact.Open()

rsContact_numRows = 0
%>
<html><!-- InstanceBegin template="/Templates/COPSTEMP2.dwt.asp" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>COPSNetTemp</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>
<font color=blue></font id=blue>

Reply to this topic