I have a form that submits to a table. This works great using a dsn to connect to the db. When I switch to using an include file dsnless and placing the connection in a variable name strconnect. I get the following error:
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: 'objconn'
/checkbox/add_action.asp, line 69
The only diffrence between the dsn and dsnless version are
top of dsnless page
'option explicit
Dim strconnect
Dim orsco
%>
<!--METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<!--#include file="connection.asp"-->
where the objconn is made on the dsnless
'Create and open the database object
Set objconn = server.createobject("ADODB.Connection")
objConn.Open, strconnect
The same bit of code on the one that uses a dsn
'Create and open the database object
Set objconn = server.createobject("ADODB.Connection")
objConn.Open, "dsn=onsite"
All the dsnless code
<%
'option explicit
Dim strconnect
Dim orsco
%>
<!--METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<!--#include file="connection.asp"-->
<html>
Process the article
<%
'Declare variable needed
Dim strInsert
Dim strValue
Dim AdCmdText
Dim blnCrticalError
'Set required variables
adCmdText = 1
'if an add was requested add a new article to the table.
If Request.Form ("") = "Add" Then
'start building the SQL string with the required fields
strInsert = "Insert into tblonsite (article_date,article_text"
strValues = "Values('" &CStr &(Request.Form("txtArticle_date")) &_
"','" & CStr(Request.Form("txtArticle_text")) & "'"
'Add acive if checked
If Request.Form("") = 1 Then
'Add the column name to the insert string
strInsert = strInsert &",article_status"
'Add true to the value string
strValue = strValue & ",True"
End If
'Create and open the database object
Set objconn = server.createobject("ADODB.Connection")
objConn.Open, strconnect
'Create the command object
set objCmd = Server.CreateObject("ADODB.Command")
'set the command object properties
Set objCmd.ActiveConnection = objConn
objCmd.CommandText = strInsert & ") " & strValues & ")"
objcmd.Commandtype = adcmdtext
'execute the command
objcmd.execute
'display the insert string
Response.Write "the following insert string was executed " &_
"and the value inserted into the article table.</p>"
Response.Write strInsert & ") " & strValue & ")"
End If
'Close and clean
set objcmd = nothing
69 objconn.close
set objconn = nothing
%>
The form is submitting all the info. I've response.write that. How can I fix this?