Solved

DSNless Connection String

Posted on 2007-03-23
10
282 Views
Last Modified: 2010-04-25
I am attempting a DSNless connection to an Access Database.  Here is the connection string:
<%
var MM_NCIMHC2_STRING = strConnection = "DBQ=" & server.mappath("\CS\NCIMHC\Database\NCIMHC.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"
%>
This resides on an ASP page in the connections folder and is called NCIMHC2.asp

The asp code to connect to the databse using the DSNless sting is as follows:
<!--#include virtual="/CS/Connections/NCIMHC2.asp" -->
<%
var Recordset1 = Server.CreateObject("ADODB.Recordset");
Recordset1.ActiveConnection = MM_NCIMHC2_STRING;
Recordset1.Source = "SELECT * FROM NCIMHC";
Recordset1.CursorType = 0;
Recordset1.CursorLocation = 2;
Recordset1.LockType = 1;
Recordset1.Open();
var Recordset1_numRows = 0;
%>

I get the following error:

Microsoft JScript runtime error '800a1391'

'server' is undefined

/CS/Connections/NCIMHC2.asp, line 2

I assume this has to do with the sever.mappath in the connection string but am unclear as to why.  I appreciate your wisdom and wil award accordingly.
0
Comment
Question by:bleckron
  • 4
  • 4
10 Comments
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Hello

I could be wrong but does server not have to be uppercase ie Server

also this is not a valid string

var MM_NCIMHC2_STRING = strConnection = "DBQ=" & server.mappath("\CS\NCIMHC\Database\NCIMHC.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"

Scott
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
actually it might be valid i think i read it wrong

sorry

Scott
0
 

Author Comment

by:bleckron
Comment Utility
Ihave now changed the connection string to :

<%
var MM_NCIMHC2_STRING = "DBQ=" & Server.MapPath("\CS\NCIMHC\Database\NCIMHC.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;"
%>

And now get the following error:

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/CS/NCIMHC/Test.asp, line 5
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
A good reference for connection strings:

http://www.connectionstrings.com/

in particular

http://www.connectionstrings.com/?carrier=access

try that as an example

Scott
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:bleckron
Comment Utility
I tried the examples to no avail...
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
try doing a response.write on MM_NCIMHC2_STRING just to see what is getting set
0
 

Author Comment

by:bleckron
Comment Utility
I get a "0".  I t must not be getting to the databse.  The conection sstring must not be right somehow?
0
 

Author Comment

by:bleckron
Comment Utility
I figured it out:

<%
 FileName="Connection_ado_conn_string.htm"
 Type="ADO"
 DesigntimeType="ADO"
 HTTP="true"
 Catalog=""
 Schema=""
var MM_NCIMHC_STRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+ Server.MapPath("/CS/NCIMHC/Database/NCIMHC.mdb")
%>

I am using Javascript so needed to use DSNless connectin with Javascript.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
Comment Utility
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now