p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

proasp_howto thread: RDS Objects & connecting to Db


Message #1 by melody.siska@5... on Thu, 29 Jun 2000 13:57:23
are you sure you can access this object in this way?:
Set rsAutoYears = document.form.Years.Recordset

-----Original Message-----
From: Siska, Melody [mailto:Melody.Siska@5...]
Sent: Thursday, June 29, 2000 5:47 PM
To: How To
Subject: [proasp_howto] RE: RDS Objects & connecting to Db


This application will be used strictly on an intranet. Here is a condensed
version of my code:

<%@ Language=VBScript %>
<%
	'---These lines are so when user uses BACK btn form is reloaded---
	Response.CacheControl = "no-cache"
	Response.AddHeader "Pragma", "no-cache"
	Response.Expires = -1
 %>
<HTML>
<HEAD>
<META name=VI60_DTCScriptingPlatform content="Server (ASP)">
<META name=VI60_defaultClientScript content=VBScript>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<META Http-Equiv="Pragma" Content="no-cache">
<META Http-Equiv="Cashe-Control" Content="no-cache">

<SCRIPT Language=VBScript>
	Sub newMake()
		'---Create a SQL stmt based on selected make---
		'---This will fill the cbo_Years with valid years for the
selected make
		document.form.Years.SQL = "SELECT DISTINCT year FROM
VehicleDesc WHERE make= '" & _

document.form.cbo_Make.options(document.form.cbo_Make.selectedIndex).text &
"' ORDER BY year DESC"
		document.form.Years.Refresh
	End Sub
</SCRIPT>
</HEAD>

<BODY tabindex=-1 BgColor="#000000" text="#ffffff" vlink = "#FFFFFF" link 
"#FFFFFF">
<% '---Connect to database---
	Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
	OBJdbConnection.Open "NADA", "NADA", "NADA"
	SQLQuery = "SELECT DISTINCT Make FROM VehicleDesc ORDER BY Make"
	Set rs_Make = OBJdbConnection.Execute(SQLQuery)
	rs_Make.MoveFirst
%>

<FORM Name='form'>
<!-- A dataControl object that'll get the make's available years -->
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
	ID="Years" width=1 height=1 tabindex=-1>   
	<PARAM NAME="Server"
VALUE="http://<%=Request.ServerVariables("SERVER_NAME") %>">
	<PARAM NAME="Connect"  VALUE="dsn=NADA;UID=NADA;PWD=NADA">
	<PARAM NAME="SQL" VALUE="SELECT DISTINCT year FROM VehicleDesc WHERE
MAKE ='<%=rs_Make("Make")%>' ORDER BY year DESC">
</OBJECT>

<SCRIPT language = VBScript FOR=Years event=onReadyStateChange>
	Dim rsAutoYears
	If Years.ReadyState = 4 Then
		j = document.form.cbo_Year.length
		for i = 1 to j
			document.form.cbo_Year.remove(1)
		next
		Set rsAutoYears = document.form.Years.Recordset
		Do While Not rsAutoYears.eof

			'---create a new Option element---
			Set NewOption = document.createElement("OPTION")
			NewOption.text = rsAutoYears("year")
			NewOption.value = rsAutoYears("year")
			NewOption.selected = true

			'---add the element to the list---
			document.form.cbo_Year.add(NewOption)

			'---get the next record---
			rsAutoYears.MoveNext
		loop
		document.form.cbo_Year.selectedIndex = 0
	End If
	</SCRIPT>
<SELECT  name="cbo_Make">

<%	holdMake = rs_Make("make")
	Do While Not rs_Make.EOF
%>

	<OPTION><%= rs_Make("Make")%></OPTION>

<% 	rs_Make.MoveNext
	Loop
%>
</SELECT>
<SELECT name=cbo_Year onChange=newYear() tabindex=5>
<OPTION> Select a Year </OPTION>
</SELECT>
</FORM>
</BODY>
</HTML>

-----Original Message-----
From: Ruud Voigt [mailto:RuudVoigt@w...]
Sent: Thursday, June 29, 2000 10:55 AM
To: How To
Subject: [proasp_howto] RE: RDS Objects & connecting to Db


Hi,
I can't figure out where the error is occuring.
I assume it's on the client but in the code
you've posted here nothing is being done with
the object, are you accessing the client side
object with some script when the error occurs?.
Do you know in which line the error occurs?

also
are you sure this is correct:
VALUE="http://<%=Request.ServerVariables("SERVER_NAME") %>">
as far as i can see this will only work on an intranet.

Eventhough you haven't gotten the book yet you still could get
the source code to 'ADO RDS with asp' from the wrox website.
It has some pretty good RDS examples.




-----Original Message-----
From: melody.siska
Sent: Thursday, June 29, 2000 1:57 PM
To: How To
Subject: [proasp_howto] RDS Objects & connecting to Db


Hi,

  I am pretty new to writing asp. I would appreciate any help. I am writing
an asp that uses RDS. I first hosted this on my computer which has PWS. I
was able to use my computer and others as a client to connect to my asp.
Now I tried to move it to our company test server. It is an SQL Server 7.0.
I set a DSN (ODBC?) on the SQL server called NADA.
For my first connection I used:

<% 'Connect to database
	Set OBJdbConnection = Server.CreateObject("ADODB.Connection")
	OBJdbConnection.Open "NADA", "NADA", "NADA"
	SQLQuery = "SELECT DISTINCT Make FROM VehicleDesc ORDER BY Make"
	Set rs_Make = OBJdbConnection.Execute(SQLQuery)
	rs_Make.MoveFirst
%>

This worked on both my computer and on the SQL server. My problem is that
my objects (RDS) are not working. The code I am using is:

<!-- A dataControl object that'll get the make's available years -->
<OBJECT CLASSID="clsid:BD96C556-65A3-11D0-983A-00C04FC29E33"
	ID="Years" width=1 height=1 tabindex=-1>   
	<PARAM NAME="Server"
VALUE="http://<%=Request.ServerVariables("SERVER_NAME") %>">
	<PARAM NAME="Connect"  VALUE="dsn=NADA;UID=NADA;PWD=NADA">
	<PARAM NAME="SQL" VALUE="SELECT DISTINCT year FROM VehicleDesc WHERE
MAKE
='<%=rs_Make("Make")%>' ORDER BY year DESC">
</OBJECT>

I get an error that says: "The operation requested by the application is
not allowed if the object is closed." I believe that the recordset of my
object is not being created, I am not making the correct connection.

Can anyone tell me what I can do to make this work? Or what else I could
try? Or any other information that is needed to find out what I need to do?
I would truly appreciate any feed back!! I have ordered Papa's book on RDS
& ADO but I have not yet received it in the mail. I have Wrox VBScript book
& Wrox, Kauffman's Beginning ASP Databases.

Feel free to either post responses or to e-mail me at melody.siska@5...
Thank you in advance!
Melody



---
Wrox Professional Wireless Developer Conference, Amsterdam, July 10-12.
Covering application of WAP, XML, ASP, Java and C++ to wireless computing,
choose from 40+ technical sessions delivered by industry experts:
http://www.wroxconferences.com/ConferenceHome.asp?ConfID=9
---
You are currently subscribed to proasp_howto.

---
Wrox Professional Wireless Developer Conference, Amsterdam, July 10-12.
Covering application of WAP, XML, ASP, Java and C++ to wireless computing,
choose from 40+ technical sessions delivered by industry experts:
http://www.wroxconferences.com/ConferenceHome.asp?ConfID=9
---
You are currently subscribed to proasp_howto.


  Return to Index