Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2004, 12:13 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default PWS Connection String

is there any difference of database connection between IIS and
PWS ? when i use same code at IIS there is no problem code run sucessfully when i run under PWS with windows 98 the error shown at
connection string my connection string as follows

connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "& server.MapPath("../admin/_db/online_db.mdb")
conn.open = connstring

what can i do



 
Old June 24th, 2004, 12:22 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Check the syntax, is it
conn.open = connstring
or
conn.open connstring

Om Prakash
 
Old June 24th, 2004, 12:50 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

i said there is no problem in IIS and i have post my code
then why u say check!!!!!!
conn.open = connstring
is it wrong

 
Old June 24th, 2004, 01:47 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, you can say what you want, but the tip to check is very good, because that is exactly what you have to do:

conn.open = connstring

will NOT run on IIS either. Maybe code that looks like it, but this certainly won't run. You can't assign a connection string to the connection's Open method. Try this (as suggested by om_prakash, but maybe you don't want to hear it again):

conn.open connstring

That should run on PWS and on IIS.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old June 24th, 2004, 04:15 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

no imar it is sucessfully run in IIS u can try this urself


 
Old June 24th, 2004, 04:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Knight,

AFAIK, connectionstring can be assigned to a Connection object's connectionstring property. Not to the open method.

Open method can take connection string as a parameter. So IMO it shouldn't work, though you say it works, I doubt if that is a valid approach.

You can check this page for conneciton objects properties and methods, with examples on theis usages too.

http://www.w3schools.com/ado/ado_ref_connection.asp

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 24th, 2004, 04:30 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

I hate to spoil your day, but you're plain wrong. The Open method of the Connection object is a method, not a property. So, you cannot assign it a connection string like you are doing.

Take a look here: http://msdn.microsoft.com/library/de...connection.asp

This is what the docs say:

connection.Open ConnectionString, UserID, Password, Options

As you can see, as an argument you can pass a connection string to the connection object's Open method. You cannot assign that connection string.

The connection object does have a ConnectionString property, so before you call Open, you can assign a connection string like this:

MyConnection.ConnectionString = MyConnectionString
MyConnection.Open()

Maybe your code "works" in IIS because you have On Error Resume Next in your page, or something like that.

If you insist it's supposed to work, can you post a full and complete example with, say, the Northwind database that runs fine on IIS? I'd really like to see it.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Car Crash by Tricky (Track 4 from the album: Vulnerable) What's This?
 
Old June 24th, 2004, 06:42 AM
Authorized User
 
Join Date: Feb 2004
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to knight
Default

ok then
check the following codes its work fine both cases
conn.open = connstring
and
conn.open connstring here are codes u can use ur own database
-------------------------------
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
dim conn, connstring
set conn = Server.Createobject("ADODB.connection")
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = "& server.MapPath("./admin/_db/online_db.mdb")
conn.open = connstring
set rs=Server.CreateObject("ADODB.recordset")
rs.Open "Select * from users", conn
for each x in rs.fields
   response.write(x.name)
   response.write(" = ")
   response.write(x.value)
   response.write("<br>")
next
conn.close
Set conn=Nothing
%>
</body>
</html>



 
Old June 24th, 2004, 07:12 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You are right Knight. To my wonder that works giving NO errors in IIS.

It works when I used conn.open = connstring

But I found it documented nowhere. That is a surprise. Can't explain on that really.

_________________________
-Vijay G
Strive for Perfection
 
Old June 24th, 2004, 07:20 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Same here. Sorry about all this, it does indeed work.

It works as you said. But, afaics, this is not supposed to work according to the docs. Maybe this is a undocumented feature, or maybe it works because of some other odd reason.

Funny thing is, you can substitute the = for a + and it still works:

conn.open + connstring

runs fine. If you then write out the ConnectionString property, you get a valid connection string.

Bottom line: it works, but it's not supposed to be used like this. Just pass the connectionstring as an argument to the Open method, or set the ConnectionString property on the Connection object.

Sorry again for saying you were plain wrong.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: donuts and porno by KoRn (Track 9 from the album: Undefined) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
connection string kooky SQL Server ASP 1 February 14th, 2008 09:59 AM
Connection String slgknjn VB Databases Basics 2 February 26th, 2005 03:14 AM
Connection String aadz5 JSP Basics 1 January 24th, 2005 04:36 AM
Connection string tlamazares SQL Server ASP 1 March 29th, 2004 05:16 PM
connection string aadz5 ASP.NET 1.0 and 1.1 Basics 4 October 20th, 2003 08:43 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.