Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 September 20th, 2004, 11:14 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to hcweb
Default Connection Strings

I'm using the connection string examples in ASP 3.0 to connect to local databases. However, I have another server on my network that I would like to connect to via connection string to retrieve data from. I'm unsure of how to properly edit the below connection string to access the remote DB. If anyone has a better way of making this connection, then I'm all ears! Thanks in advance!

<%
Dim strDataBaseType

strDataBaseType="Access"
strConnect = "provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=?;" & _
"Persist Security Info=False"
%>
 
Old September 20th, 2004, 07:08 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Here is my global.inc file with 'I believe all the types of access connection string you will ever need'

The one I mainly use is uncommented, I use access only when forces to do so. You can not claim true scalability using Access due to it's size limitations. Access conn strings are very fussy and must be exact!!
----------------------------------
<%
Response.Buffer = True
Response.CacheControl = "No-cache"
Response.Expires = 0

const sMainDb = "DB/DBName.mdb"
const URLBase = "http://www.matthewburr.com"
const MailEnabled = false

Dim Conn,sql,getInfo,EoF,accessedFigure,duplicate,Reco rdFound

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\Inetpub\wwwroot\labfit\DB\DBName.m db"
'OTHER CONNECTION STRINGS

'Conn.open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("../DB/DBName.mdb")

'DSNless (ADO) Connection Strings
'standard connection string
'Conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=C:\Inetpub\wwwroot\labfit\DB\DBName.m db"
'map path connection string
'Conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("../DB/DBName.mdb") & ";"

'OLEDB Connection Strings
'standard connection string
'Conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\labfit\DB\DBName.mdb"
'map path connection string
'Conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../DB/DBName.mdb")
%>

Wind is your friend
Matt
 
Old September 21st, 2004, 07:08 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Mat, I'm sorry to say that none of your examples will connect to a remote access db. OP will need
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=\\myServer\myShare\myPath\myDb.mdb"

Also, sorry to say you should not use the ODBC versions (DRIVER={Microsoft Access Driver (*.mdb)}) from ASP - they're just not suitable. See http://support.microsoft.com/default.aspx?kbid=222135
Quote:
quote:
When running Microsoft Jet in an IIS environment, it is recommended that you use the native Jet OLE DB Provider in place of the Microsoft Access ODBC driver. The Microsoft Access ODBC driver (Jet ODBC driver) can have stability issues due to the version of Visual Basic for Applications that is invoked because the version is not thread safe. As a result, when multiple concurrent users make requests of a Microsoft Access database, unpredictable results may occur. The native Jet OLE DB Provider includes fixes and enhancements for stability, performance, and thread pooling (including calling a thread-safe version of Visual Basic for Applications).
Anyway, back to the original problem. hcweb the connection string is the simplest to sort. The problems usually come in assigning the appropriate permissions. Because ASP runs as a local acccount (usually IUSR_MachineName) on the web server then other machines on the network don't even know that this user exists, therefore the network machine won't grant access to the db. See the archive http://p2p.wrox.com/topic.asp?TOPIC_ID=8791 (Problem accessing folder on LAN) for the solution - I know this topic is .NET but the principles of permissions are the same under classic ASP.

hth
Phil
 
Old September 21st, 2004, 06:45 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I am curious, what is the difference between this one and the one you suggested.
  'standard connection string
  'Conn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\labfit\DB\DBName.mdb"


Wind is your friend
Matt
 
Old September 22nd, 2004, 05:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Matt, yeh OK technically its the same, but as the OP obviously didn't know what to put in the Data Source bit, it seemed to me that giving an example with a path to a local file wasn't going to help.

rgds
Phil
 
Old September 22nd, 2004, 06:48 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

Yes, I see. Sorry OP I thought that was the logical bit. Access connection strings have always been a headache for me (the part that preceeds the path). All the ones in that global.asa file I got from the MS web site, one of them always works. Strangly enough, one that works on one server/site fails to work on another for no real obvious reason (same platfrom, os and sometimes the same dir structure)

Phil - I have just looked at some of my currently live access conn strings, I have used the one you have suggested as un suitable, is this a problem? As I said it came from the MS web site and is currenly working trouble free, do you suggest I change this?

Wind is your friend
Matt
 
Old September 23rd, 2004, 03:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Personally I would change it. OK the wording in the MSKB is vague with phrases like "...can have stability issues..." and "...unpredictable results may occur...", but chances are the problems will start to happen just when you really don't want them to.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection Strings WFletch Visual Basic 2008 Essentials 1 July 14th, 2008 09:42 AM
Securing connection strings haines ASP.NET 2.0 Basics 1 March 2nd, 2008 04:28 PM
Using Connection Strings - App.config testsubject Visual Studio 2005 1 July 16th, 2007 01:08 AM
Connection Strings WillyWonker BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 3 January 25th, 2005 10:40 AM
Multiple DSN's using connection strings hcweb Classic ASP Basics 1 February 23rd, 2004 02:42 AM





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