DSN Connection

Results 1 to 2 of 2

Thread: DSN Connection

  1. #1
    Join Date
    Dec 1969

    Default DSN Connection

    I have downloaded the source code for a bulletin board from<BR><BR>http://www.ultimateasp.com/free/downloads.asp<BR><BR>However this does not come with any instructions for installation. The code for establishing the database connection is as follows (the database is called Bulletin.mdb):<BR><BR> <BR><BR>Sub OpenDB (ByRef con, d)<BR><BR>DB = d & ".mdb"<BR><BR>Dir = Request.ServerVariables("SCRIPT_NAME")<BR><BR>Dir = StrReverse(Dir)<BR><BR>Dir = Mid(Dir, InStr(1, Dir, "/"))<BR><BR>Dir = StrReverse(Dir)<BR><BR>Path = Server.MapPath(Dir) & "\"<BR><BR>f = "ms_access.dsn"<BR><BR>DSN = "filedsn=" & Path & f & ";DefaultDir=" & Path & ";DBQ=" & Path & DB & ";"<BR><BR>Set con = Server.CreateObject("ADODB.Connection")<BR><BR>con .Open DSN<BR><BR>End Sub<BR><BR>When you unzip the files there is a Microsoft OLE DB Provider for ODBC Drivers file called ms_access. What am I ment to do with this? How to I setup the ODBC for PWS i.e. what datasource name should I be using etc.? Also how do I set this up when I eventually post the site on an exteranal server?<BR><BR>Thanks in advance for all your help,<BR><BR> <BR><BR>Ross<BR><BR> <BR>

  2. #2
    peterjl@atlantech.com.au Guest

    Default RE: DSN Connection

    I use DSN-less connection and it seems to work well. It goes like this:<BR><BR>***dbpath = server.mappath("/db/mydb.mdb")<BR>&#039 this gives my the filesytem path via the virtual path of my DB<BR>***cnstring="Provider=Microsoft.Jet.OLEDB .3.51; Data Source=" & dbpath & ";"<BR>&#039 and puts it into a connection string<BR>***set conn = server.createobject("ADODB.Connection")<BR>***c onn.open cnstring <BR>&#039 to setup the db connection<BR>***set rs=server.createobject("ADODB.RecordSet")<BR>** *rs.open "select * from MyTable", Conn, 2, 3, 1<BR>&#039 Use the connection to open a recordset for the table.<BR><BR>There are some good articles on the subject in www.4guysfromrolla.com - 1999 articles.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts