Wrox Home  
Search P2P Archive for: Go

  Return to Index  

interdev_programming thread: Can't get connection string working for any dbases


Message #1 by "Kirsten Czupryna" <kirsten_czupryna@l...> on Fri, 21 Feb 2003 18:40:09
Hi Kirsten,

You sometimes get that error when no recordset is produced. It might be your
SQL statement. It looks like you might want a table join such as...

SELECT products.product_id, products.name,
products.price, products.thumbnail, product_type.type_description
FROM products
JOIN product_type
  ON products.product_id = product_type.product_id

WHERE products.type_id = product_type.product_type

ORDER BY name

Of course your fields may be different than the ones I suggested.

--
________________________________________
John Belthoff                   Aicite Communications
________________________________________



-----Original Message-----
From: Kirsten Czupryna [mailto:kirsten_czupryna@l...]
Sent: Friday, February 21, 2003 6:40 PM
To: Interdev_Programming
Subject: [interdev_programming] Can't get connection string working for
any dbases


Hi all - I'm working my way thru Beginning VisInterdev, and am having lots
of difficulty with Chapter 9 - ADO. I'm trying to connect to my
camerastoredb database from my products.asp page (p. 274):

First, I set the database up in SQL Server 2000 on Win2000 machine, but
abandoned that idea because I still don't know enough about permissions
and security with that program to login to my database. (That's a whole
separate course!)

So, I copied the database from SQL Server 2000 to Access, thinking it
would be easier to get around security issues and focus directly on
learning ADO. But I still can't access my database. It's name is
camerastoredb.mdb.

I have pasted the code I'm trying to use in products.asp. The last error
message I got was "ADODB.ConnectionError 800a0bb9: Argument of wrong type,
out of range, or in conflict with each other."

Can anyone take a look and give me a hint as to what I'm doing wrong?
I thought Access was supposed to be easier! :)
Thanks in advance,
Kirsten

<%
'retrieve catalogue of products from DB and write to table
Dim adoConn
Dim adoCmd
Dim adoRS
Dim strConnectionString

'create ADO objects
Set adoConn = Server.CreateObject("ADODB.Connection")
Set adoCmd = Server.CreateObject("ADODB.Command")
Set adoRS = Server.CreateObject("ADODB.Recordset")

strConnectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\databases\camerastoredb.mdb;User ID=Admin;Password="""

adoCmd.CommandType = adCmdText
adoCmd.CommandText = "SELECT products.product_id, products.name,
products.price, products.thumbnail,product_type.type_description FROM
products, product_type WHERE products.type_id = product_type.product_type
ORDER BY name"
'open the connection
adoConn.Open strConnectionString

'associate the Command with the Open Connection
adoCmd.ActiveConnection = adoConn

'retrieve recordset
Set adoRS = adoCmd.Execute

Do While not adoRS.EOF
	'process results to create table
	Response.Write "<TR>" & vbcrlf
	Response.Write "<TD><a href=" & chr(34) & "product_details.asp?
product_ID=" &_
		adoRS("product_id").value & chr(34) & "><IMG SRC=" & chr
(34) &_
		"images/" & adoRS("thumbnail").value & chr(34)
& "></a></TD>" & vbcrlf
	Response.Write "<TD>" & adoRS ("name").value & "</TD>" & vbcrlf
	Response.Write "<TD>" & adoRS ("price").value & "</TD>" & vbcrlf
	Response.Write "<TD>" & adoRS ("type_description").value
& "</TD></TR>" & vbcrlf
	adoRS.MoveNext
Loop

'close connection and release resources
adoConn.Close
Set adoConn = nothing
Set adoCmd = nothing
Set adoRS = nothing

%>
</TABLE>
</BODY>
</HTML>





  Return to Index