|
 |
asp_databases thread: cannot connect to my database
Message #1 by Rowenap@w... on Thu, 28 Sep 2000 10:50:15 +0100
|
|
-----Original Message-----
From: Maurice Duckett [mailto:mduckett@M...]
Sent: 27 September 2000 15:55
To: 'support@w...'
Subject: cannot connect to my database
I have been reading your books on begining ASP and ASP Databases
The other day I purchased Professional ADO 2.5 RDS programming with ASP
3.0
and cannot seem to find a way to connect to my database
i used to connect like this
<%
Dim oSchedule
Set oSchedule = Server.CreateObject("ADODB.Recordset")
oSchedule.open "Select * from madden", "DSN=moe"
%>
but that doesn't allow for moving previous, etc.....
from reading chpater 3 in the ado rds book i have been trying to connect
with a dsn-less connection. but cannot. my code looks like this:
<%
Set objConn = CreateObject("ADODB.Connection")
Dim strConn
strConn = "File Name=c:\databases\moe.dsn; Data
Source=c:\databases\MOE.mdb;
INITIAL CATALOG=MADDEN"
objConn.Open strConn
set Session("Connection") = objConn
strSQL = "SELECT * FROM madden"
Set objConn = Session("Connection")
Set objRSData = objConn.Execute(strSQL)
%>
i did the little trick for dsn-connections on page 45 and my moe.dsn file
contains this:
[ODBC]
DRIVER=Microsoft Access Driver (*.mdb)
UID=admin
UserCommitSync=Yes
Threads=3
SafeTransactions=0
PageTimeout=5
MaxScanRows=8
MaxBufferSize=2048
FIL=MS Access
DriverId=25
DefaultDir=C:\Databases
DBQ=C:\Databases\MOE.mdb
Message #2 by "Ken Schaefer" <ken@a...> on Fri, 29 Sep 2000 10:47:27 +1000
|
|
Maurice,
Look at OLEDB instead of ODBC:
http://www.adOpenStatic.com/faq/whyOLEDB.asp
You should *never* do this. Never put ADO objects into session or
application variables.
> set Session("Connection") = objConn
Don't use SELECT * either
http://www.adOpenStatic.com/faq/selectstarisbad.asp
If you want some simple code, do this:
<%
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source="c:\databases\MOE.mdb"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open strConnect
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.Open "Madden", objConn, adOpenForwardOnly, adLockReadOnly,
adCmdTableDirect
' If you need to scroll backwards etc, change adOpenForwardOnly to
adOpenStatic
' Don't forget to define your ADO constants:
' http://www.adopenstatic.com/faq/800a0bb9step2.asp
' and to .close and Set = nothing your ADO objects when you don't need them
%>
Cheers
Ken
----- Original Message -----
From: <Rowenap@w...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, September 28, 2000 7:50 PM
Subject: [asp_databases] cannot connect to my database
> -----Original Message-----
> From: Maurice Duckett [mailto:mduckett@M...]
> Sent: 27 September 2000 15:55
> To: 'support@w...'
> Subject: cannot connect to my database
>
>
>
> I have been reading your books on begining ASP and ASP Databases
>
> The other day I purchased Professional ADO 2.5 RDS programming with ASP
> 3.0
> and cannot seem to find a way to connect to my database
>
> i used to connect like this
> <%
> Dim oSchedule
> Set oSchedule = Server.CreateObject("ADODB.Recordset")
> oSchedule.open "Select * from madden", "DSN=moe"
> %>
> but that doesn't allow for moving previous, etc.....
>
> from reading chpater 3 in the ado rds book i have been trying to connect
> with a dsn-less connection. but cannot. my code looks like this:
>
> <%
>
> Set objConn = CreateObject("ADODB.Connection")
> Dim strConn
> strConn = "File Name=c:\databases\moe.dsn; Data
> Source=c:\databases\MOE.mdb;
> INITIAL CATALOG=MADDEN"
> objConn.Open strConn
> set Session("Connection") = objConn
>
> strSQL = "SELECT * FROM madden"
>
> Set objConn = Session("Connection")
> Set objRSData = objConn.Execute(strSQL)
> %>
>
> i did the little trick for dsn-connections on page 45 and my moe.dsn file
> contains this:
>
> [ODBC]
> DRIVER=Microsoft Access Driver (*.mdb)
> UID=admin
> UserCommitSync=Yes
> Threads=3
> SafeTransactions=0
> PageTimeout=5
> MaxScanRows=8
> MaxBufferSize=2048
> FIL=MS Access
> DriverId=25
> DefaultDir=C:\Databases
> DBQ=C:\Databases\MOE.mdb
>
|
|
 |