Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Insert Statement problem

Status
Not open for further replies.

martin1000

Programmer
Nov 29, 2000
3
US
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(&quot;Action&quot;) = &quot;Add&quot; Then
29:
30: 'start building the SQL string
31: strInsert = &quot;Insert into SSTP1 (ProgramTitle&quot;
32: strValues = &quot;Values('&quot; & CStr(Request.Form(&quot;ProgramTitle&quot;)) & &quot;'&quot;
...
370: 'Create and Open the database object
371: Set objConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
372: objConn.Open &quot;DSN=STP&quot;
373:
374: 'Create the command object
375: Set objCmd = Server.CreateObject(&quot;ADODB.Command&quot;)
376:
377: 'Set the command object properties
378: Set objCmd.ActiveConnection = objConn
379: objCmd.CommandText = strInsert & &quot;) &quot; & strValues & &quot;)&quot;
380: objCmd.CommandType = adCmdText
381:
382: 'Execute the command
383: objCmd.Execute
384:
385: 'Display the update string
386: Response.Write &quot;The following insert string was executed and the values inserted into the STP table.<p>&quot;
387: Response.Write strInsert & &quot;) &quot; & strValues & &quot;)&quot;
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: %>
 
I figured out the problem. After hours looking into what was wrong, I realized that line 28

If Request.Form(&quot;Action&quot;) = &quot;Add&quot; Then

is case sensitive and should be

If Request.Form(&quot;action&quot;) = &quot;add&quot; Then

because action and add in the form are not capitalized.

Hope this helps someone.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top