martin1000
Programmer
I seem to be having a problem with my SQL insert statement. I am not sure what the problem is, but I'm pretty sure it is the SQL insert statement (lines 31-32 and 379). I get the error message:
Microsoft VBScript runtime error ' 800a01a8'
Object required: ''
/STPEdit/addupdate.asp, line 396
I have checked the database field names and they are ok. The form field names are correct also. Is it a punctuation problem (comma, quote, etc.)? Thanks in advance.
Here is the code:
14: <%
15: 'declare variables needed
16: Dim strInsert
17: Dim strValues
18: Dim adCmdText
19: ' Dim blnCriticalError
20: Dim objConn
21: Dim objCmd
22:
23: 'set required variables
24: adCmdText=1
25:
26: 'If an Update was requested, update the club in the database
27:
28: If Request.Form("Action" = "Add" Then
29:
30: 'start building the SQL string
31: strInsert = "Insert into SSTP1 (ProgramTitle"
32: strValues = "Values('" & CStr(Request.Form("ProgramTitle") & "'"
...
370: 'Create and Open the database object
371: Set objConn = Server.CreateObject("ADODB.Connection"
372: objConn.Open "DSN=STP"
373:
374: 'Create the command object
375: Set objCmd = Server.CreateObject("ADODB.Command"
376:
377: 'Set the command object properties
378: Set objCmd.ActiveConnection = objConn
379: objCmd.CommandText = strInsert & " " & strValues & ""
380: objCmd.CommandType = adCmdText
381:
382: 'Execute the command
383: objCmd.Execute
384:
385: 'Display the update string
386: Response.Write "The following insert string was executed and the values inserted into the STP table.<p>"
387: Response.Write strInsert & " " & strValues & ""
388:
389: End If 'End If for step processing
390:
391: 'Close and dereference database objects
392: Set ObjCmd = Nothing
393: objConn.Close
394: Set objConn = Nothing
395: %>
Microsoft VBScript runtime error ' 800a01a8'
Object required: ''
/STPEdit/addupdate.asp, line 396
I have checked the database field names and they are ok. The form field names are correct also. Is it a punctuation problem (comma, quote, etc.)? Thanks in advance.
Here is the code:
14: <%
15: 'declare variables needed
16: Dim strInsert
17: Dim strValues
18: Dim adCmdText
19: ' Dim blnCriticalError
20: Dim objConn
21: Dim objCmd
22:
23: 'set required variables
24: adCmdText=1
25:
26: 'If an Update was requested, update the club in the database
27:
28: If Request.Form("Action" = "Add" Then
29:
30: 'start building the SQL string
31: strInsert = "Insert into SSTP1 (ProgramTitle"
32: strValues = "Values('" & CStr(Request.Form("ProgramTitle") & "'"
...
370: 'Create and Open the database object
371: Set objConn = Server.CreateObject("ADODB.Connection"
372: objConn.Open "DSN=STP"
373:
374: 'Create the command object
375: Set objCmd = Server.CreateObject("ADODB.Command"
376:
377: 'Set the command object properties
378: Set objCmd.ActiveConnection = objConn
379: objCmd.CommandText = strInsert & " " & strValues & ""
380: objCmd.CommandType = adCmdText
381:
382: 'Execute the command
383: objCmd.Execute
384:
385: 'Display the update string
386: Response.Write "The following insert string was executed and the values inserted into the STP table.<p>"
387: Response.Write strInsert & " " & strValues & ""
388:
389: End If 'End If for step processing
390:
391: 'Close and dereference database objects
392: Set ObjCmd = Nothing
393: objConn.Close
394: Set objConn = Nothing
395: %>