Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Does anyone use www.1asphost.com for hosting? Need help connecting to database??


Message #1 by "Jeremy Simpson" <jsimpson34@e...> on Thu, 3 Oct 2002 20:22:33
I'm testing some ASP pages using www.1asphost.com and am having trouble 
connecting to my database. Here is the code they suggest for connecting


How do I setup a DSN-less connection to my database?
Dim Conn

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver
(*.mdb);DBQ=" &
Server.MapPath("/USERNAME/database/yourdatabase.mdb")


Here is my ASP page. What do I need to change????
<%Option Explicit%>
<html>
<head>
<title>Testing our connection</title>
</head>

<body>

<%
    
  Dim adOpenForwardOnly, adLockReadOnly, adCmdTable
  adOpenForwardOnly = 0
  adLockReadOnly = 1
  adCmdTable = 2
  
  Dim objConn, objRS
  'set objConn = Server.CreateObject("ADODB.Connection")
  set objRS = Server.CreateObject("ADODB.Recordset")
  
  Dim strDatabaseType
  'Choose one or the following two lines, and comment out the other
  strDatabaseType = "Access"
  'strDatabaseType = "MSDE"
  
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open "DRIVER=Microsoft Access Driver
  (*.mdb);DBQ="&
  Server.MapPath("/jsimpson/database/TestASP.mdb")
  
  'Now we use this selection to open the connection in the appropriate way
  'objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  '             "Data Source=C:\TestASP.mdb;" & _
  '             "Persist Security Info=False"
  
  objRS.Open "P-Info", objConn, adOpenForwardOnly, adLockReadOnly, 
adCmdTable
  
  While Not objRS.EOF
    Response.Write objRS("Fname") & "<BR>"
    objRS.MoveNext
  Wend
  
  objRS.Close
  objConn.Close
  set objRS = Nothing
  set objConn = Nothing
  
 %>     
 
 
</body>
</html>
Message #2 by "Schelling, Michael" <schellim@s...> on Sat, 5 Oct 2002 09:16:08 -0400
Jeremy

http://www.able-consulting.com/ado_conn.htm?f=ado_conn.htm explains how to
make about any type of connection you want to make. 

Mike

-----Original Message-----
From: Jeremy Simpson [mailto:jsimpson34@e...]
Sent: Thursday, October 03, 2002 4:23 PM
To: Access ASP
Subject: [access_asp] Does anyone use www.1asphost.com for hosting? Need
help connecting to database??


I'm testing some ASP pages using www.1asphost.com and am having trouble 
connecting to my database. Here is the code they suggest for connecting


How do I setup a DSN-less connection to my database?
Dim Conn

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver
(*.mdb);DBQ=" &
Server.MapPath("/USERNAME/database/yourdatabase.mdb")


Here is my ASP page. What do I need to change????
<%Option Explicit%>
<html>
<head>
<title>Testing our connection</title>
</head>

<body>

<%
    
  Dim adOpenForwardOnly, adLockReadOnly, adCmdTable
  adOpenForwardOnly = 0
  adLockReadOnly = 1
  adCmdTable = 2
  
  Dim objConn, objRS
  'set objConn = Server.CreateObject("ADODB.Connection")
  set objRS = Server.CreateObject("ADODB.Recordset")
  
  Dim strDatabaseType
  'Choose one or the following two lines, and comment out the other
  strDatabaseType = "Access"
  'strDatabaseType = "MSDE"
  
  Set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open "DRIVER=Microsoft Access Driver
  (*.mdb);DBQ="&
  Server.MapPath("/jsimpson/database/TestASP.mdb")
  
  'Now we use this selection to open the connection in the appropriate way
  'objConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  '             "Data Source=C:\TestASP.mdb;" & _
  '             "Persist Security Info=False"
  
  objRS.Open "P-Info", objConn, adOpenForwardOnly, adLockReadOnly, 
adCmdTable
  
  While Not objRS.EOF
    Response.Write objRS("Fname") & "<BR>"
    objRS.MoveNext
  Wend
  
  objRS.Close
  objConn.Close
  set objRS = Nothing
  set objConn = Nothing
  
 %>     
 
 
</body>
</html>
Message #3 by Doods Perea <dindo.perea@a...> on Sun, 06 Oct 2002 07:34:54 +0300
Jeremy,

Try this.  I took out your other tags for better reading.

Doods



<%
    
  Dim objConn, obRS, conDB
  set objConn = Server.CreateObject("ADODB.Connection")
  set objRS = Server.CreateObject("ADODB.Recordset")

'I would use the OLEDB DSN-Less Connection (this is faster)
'  conDB = "DRIVER=Microsoft Access Driver  (*.mdb);DBQ=" &
Server.MapPath("/jsimpson/database/TestASP.mdb")
  conDB = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("/jsimpson/database/TestASP.mdb")
  objRS.Open "P-Info", conDB

'Move to the first record of the recordset
  objRS.MoveFirst
  
  While Not objRS.EOF
    Response.Write objRS("Fname") & "<BR>"
    objRS.MoveNext
  Wend
  

  objRS.Close
  'objConn.Close
  set objRS = Nothing
  set objConn = Nothing
  
 %>     
 
 


  Return to Index