navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Object required: 'objconn'

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Object required: 'objconn'
Page: [1]
 
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
Object required: 'objconn' - 3/19/2005 17:36:44   
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?
BeTheBall

 

Posts: 6362
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 19:43:05   
What's the code for connection.asp?

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 20:03:30   

quote:

ORIGINAL: BeTheBall

What's the code for connection.asp?

strconnect	=	"provider=microsoft.jet.oledb.4.0; " &_
					"data source=C:\Inetpub\wwwroot\checkbox\data\rl_company.mdb;" &_
					"persist security info=false"


(in reply to BeTheBall)
BeTheBall

 

Posts: 6362
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 20:16:20   
Rich, I haven't diversified much with connections. I have one that works and use it every time. However, in the examples I have seen, there is no comma between:

objConn.Open, strconnect

Does it help if you use just:

objConn.Open strconnect

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to mar0364)
Giomanach

 

Posts: 6112
Joined: 11/19/2003
From: England
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 20:20:51   
Hi Rich

Duane is right in the comma causing the error, I think.

You only need the comma when you are using the createobject etc to run an SQL string:

objConn.Open strSQL, strconnect

Otherwise, it's just:

objConn.Open strconnect

Just backing up Duanes point:)

_____________________________




(in reply to BeTheBall)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 20:24:43   
Thanksbut. No same error.
quote:

ORIGINAL: BeTheBall

Rich, I haven't diversified much with connections. I have one that works and use it every time. However, in the examples I have seen, there is no comma between:

objConn.Open, strconnect

Does it help if you use just:

objConn.Open strconnect


(in reply to BeTheBall)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 20:53:52   
If you use this code?

'Create and open the database object
	Set objConn = server.createobject("ADODB.Connection")
	objConn.Open strconnect
	objConn.execute (strInsert & ") " & strValue & ")"),,129

	'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
	objConn.close
	set objConn = nothing			    	
%>


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 21:15:22   

Same problem. Spooky can't solve on the first try. I may be in over my head.
quote:

'Create and open the database object
Set objConn = server.createobject("ADODB.Connection")
objConn.Open strconnect
objConn.execute (strInsert & ") " & strValue & ")"),,129

'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
objConn.close
set objConn = nothing

(in reply to Spooky)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/19/2005 23:39:12   
Using that code - it errors on which line?
(Also - post the complete page current code)

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/20/2005 7:16:38   
First thanks for helping.

Original code error on line 70
<%
 'option explicit
 Dim strconnect
 Dim orsco
%>
<!--METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<!--#include file="connection.asp"-->

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Confirmation of adding article to Intranet</title>
</head>

<body>
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 active 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	
70		objconn.close
	set objconn = nothing
			    	
%>	
</body>

</html>



Code with changes error line 58

<%
 'option explicit
 Dim strconnect
 Dim orsco
%>
<!--METADATA TYPE="typelib" FILE="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<!--#include file="connection.asp"-->

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Confirmation of adding article to Intranet</title>
</head>

<body>
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 active 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
	objConn.execute (strInsert & ") " & strValue & ")"),,129

	'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
58	objConn.close
	set objConn = nothing			    	
%>
</body>

</html>


Looks like they both error in the same place.

(in reply to Spooky)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/20/2005 14:10:49   
Hmmmm....

<%
strconnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\checkbox\data\rl_company.mdb"
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Confirmation of adding article to Intranet</title>
</head>
<body>
Process the article
<%
	'Declare variable needed
	Dim strInsert
	Dim	strValue
	Dim blnCrticalError
	
	'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 active 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
	objConn.execute(strInsert & ") " & strValue & ")"),,129

	'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
	objConn.close
	set objConn = nothing			    	
%>
</body>

</html>


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/20/2005 16:50:31   
Errors in the same darn place. I'm begining to think I should skin this cat another way. Suggestions anyone? It bugs me because this should work. I just don't get it.

Thanks
Rich

(in reply to Spooky)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/20/2005 16:55:20   
objConn.Open strconnect
response.write strInsert & ") " & strValue & ")"
response.end

objConn.execute(strInsert & ") " & strValue & ")"),,129


What does that give you?

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/20/2005 18:14:06   
Samething brother.

(in reply to Spooky)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/20/2005 18:30:05   
and if you do this?

response.write strInsert & ") " & strValue & ")"
response.end

'Create and open the database object
Set objConn = server.createobject("ADODB.Connection")
objConn.Open strconnect
objConn.execute(strInsert & ") " & strValue & ")"),,129


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/21/2005 9:20:28   
Same darn thing.

Thanks!
Rich

(in reply to Spooky)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/21/2005 13:45:48   
Are you sure you are modifying the right code then?
That should be ending the code before you even get to opening the objconn

The response end would have stopped the code in its tracks - you shouldnt have the same error.
Check exactly what file you are modifying and that you are testing the same/ right file.

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/22/2005 15:06:12   
I'll try it again when I get home tonight. I'm sure your be able to check up on it later.(wireless sheep)
quote:

ORIGINAL: Spooky

Are you sure you are modifying the right code then?
That should be ending the code before you even get to opening the objconn

The response end would have stopped the code in its tracks - you shouldnt have the same error.
Check exactly what file you are modifying and that you are testing the same/ right file.


(in reply to Spooky)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/22/2005 17:29:18   
Thanks for sticking with me here. Here is the exact code I'm running. Am I getting something wrong. The error is the same look at line 56
<%
strconnect="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\checkbox\data\rl_company.mdb"
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Confirmation of adding article to Intranet</title>
</head>
<body>
Process the article
<%
	'Declare variable needed
	Dim strInsert
	Dim	strValue
	Dim blnCrticalError
	
	'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 active 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
	
	response.write strInsert & ") " & strValue & ")" 
	response.end 

	'Create and open the database object 
	Set objConn = server.createobject("ADODB.Connection") 
	objConn.Open strconnect 
	objConn.execute(strInsert & ") " & strValue & ")"),,129 

	
	'Create and open the database object
	'Set objConn = server.createobject("ADODB.Connection")
	'objConn.Open strconnect
	'objConn.execute(strInsert & ") " & strValue & ")"),,129

	'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
line 56	objConn.close
	set objConn = nothing			    	
%>
</body>

</html>



For the heck of it here is the form the info comes from
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add article to the articles that display on the frontpage.</title>
</head>

<body>
<p>Add article to the articles that display on the frontpage.</p>
<form action="add_action1.asp" method="post" name="addfrm">
<input type="hidden" name="Action" value="Add">
Article Date<br>
<input type="text" name="article_date" size="8"/><br>
Article Text<br>
<textarea cols="50" rows="2" name="article_text"></textarea><br>
Click her if you want the article to appear on the front page. Otherwise it will appear in the article archive.<br>
<input type="checkbox" value="1" name="article_status"><br>
<input type=button name=btnsubmit value=Submit>
</form>
<script language="vbscript">
Sub btnsubmit_onclick()
If Len(addfrm.article_text.value) = 0 Then
	Alert "You must enter text"
addfrm.txtarticle_text.focus
Exit Sub	
End If
Call addfrm.submit()
End Sub
</script>
</body>

</html>

(in reply to Spooky)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/22/2005 17:32:14   
Ahhh! bingo, its not running that code

If Request.Form ("[whats this??]") = "Add" Then


'Close and clean
objConn.close
set objConn = nothing

End If ' <-- End if should be here


_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/22/2005 20:58:20   
OK now we are getting somewhere.

This is now what I get.
Process the article Insert into tblonsite (article_date,article_text) )

Seems like its not geting the values from the request object.

<%
	'Declare variable needed
	Dim strInsert
	Dim	strValue
	Dim blnCrticalError
	
	'if an add was requested add a new article to the table.
	
	If Request.Form ("Action") = "Add" Then
	'start building the SQL string with the required fields
	strInsert = "Insert into tblonsite (article_date,article_text"
	strValues = "Values('"&CStr(Request.Form("Article_date")) &_
				"','" & CStr(Request.Form("Article_text")) & "'"
				
	'Add active if checked
	If Request.Form("article_status") = 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
	
	response.write strInsert & ") " & strValue & ")" 
	response.end 

	'Create and open the database object 
	Set objConn = server.createobject("ADODB.Connection") 
	objConn.Open strconnect 
	objConn.execute(strInsert & ") " & strValue & ")"),,129 

	
	'Create and open the database object
	'Set objConn = server.createobject("ADODB.Connection")
	'objConn.Open strconnect
	'objConn.execute(strInsert & ") " & strValue & ")"),,129

	'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 & ")"
	
	
	
	'Close and clean
	objConn.close
	set objConn = nothing	
	
	End If    	
%>



(in reply to Spooky)
BeTheBall

 

Posts: 6362
Joined: 6/21/2002
From: West Point Utah USA
Status: offline

 
RE: Object required: 'objconn' - 3/22/2005 23:14:05   
Is your form by chance using the GET method (I ask because the one you emailed me did)? If so, change it to POST and see if that resolves the issue.

_____________________________

Duane

Some people are like Slinkies . . . Not really good for anything . . . . . But they still bring a smile to your face when you push them down a flight of stairs.

(in reply to mar0364)
Spooky

 

Posts: 26603
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Object required: 'objconn' - 3/22/2005 23:49:36   
At some points you use "strValue" at others, you use "strValues"

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

§þ:)


(in reply to BeTheBall)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/23/2005 7:17:54   
Its a post.

Thanks!

(in reply to BeTheBall)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/23/2005 8:52:30   
IT'S ALIVE. Outfront the best friend a web person can ever have.

Thanks! It's all about the little things.

Everyone go and have a pint on me!

quote:

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Add article to the articles that display on the frontpage.</title>
</head>

<body>
<p>Add article to the articles that display on the frontpage.</p>
<form action="add_action1.asp" method="post" name="addfrm">
<input type="hidden" name="Action" value="Add">
Article Date<br>
<input type="text" name="article_date" size="8"/><br>
Article Text<br>
<textarea cols="50" rows="2" name="article_text"></textarea><br>
Click her if you want the article to appear on the front page. Otherwise it will appear in the article archive.<br>
<input type="checkbox" value="1" name="article_status"><br>
<input type=button name=btnsubmit value=Submit>
</form>
<script language="vbscript">
Sub btnsubmit_onclick()
If Len(addfrm.article_text.value) = 0 Then
Alert "You must enter text"
addfrm.txtarticle_text.focus
Exit Sub
End If
Call addfrm.submit()
End Sub
</script>
</body>

</html>

(in reply to mar0364)
mar0364

 

Posts: 3143
Joined: 4/5/2002
From: Florida, US
Status: offline

 
RE: Object required: 'objconn' - 3/23/2005 14:04:49   
What does the 129 mean at the end of this?

It means adexecutenorecords + adCmdText

Its more efficient when doing updates, as the script doesnt expect data in return

quote:

objConn.execute(strInsert & ") " & strValue & ")"),,129


< Message edited by mar0364 -- 3/23/2005 14:11:14 >

(in reply to mar0364)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Object required: 'objconn'
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts