Old old old client code...

Results 1 to 2 of 2

Thread: Old old old client code...

  1. #1
    Join Date
    Dec 1969

    Default Old old old client code...

    Hello all...<BR>have a new client and have inherited this legacy DSN sub for an asp page that simply logs in...here&#039;s that sub...<BR><BR>Sub OpenDB (ByRef con, d)<BR> DB = d & ".mdb"<BR> Dir = Request.ServerVariables("SCRIPT_NAME")<BR> Dir = StrReverse(Dir)<BR> Dir = Mid(Dir, InStr(1, Dir, "/"))<BR> Dir = StrReverse(Dir)<BR> Path = Server.MapPath(Dir) & "\"<BR> f = "ms_access.dsn"<BR> DSN = "filedsn=" & Path & f & ";DefaultDir=" & Path & ";DBQ=" & Path & DB & ";"<BR> Set con = Server.CreateObject("ADODB.Connection")<BR> con.Open DSN<BR>End Sub<BR><BR>What I want to do is to NOT use DSN for the con, but to do away with same...but I can&#039;t make hide&#039;nor&#039;tail outta that Sub..<BR><BR>Anyone got 5 to show me what to do? IE DSN must not be used, ie I want to use a dsn-less con..<BR><BR>???<BR><BR>Jim "must be Friday by now"<BR><BR>;-)

  2. #2
    Join Date
    Dec 1969

    Default I think it's a very difficult...

    ...way of doing the following:<BR><BR>Sub OpenDB (ByRef con, d)<BR>DB = d & ".mdb"<BR>Dir = Request.ServerVariables("SCRIPT_NAME")<BR>Dir = StrReverse(Dir)<BR>Dir = Mid(Dir, InStr(1, Dir, "/"))<BR>Dir = StrReverse(Dir)<BR><BR>Get path to the script that&#039;s running now, i.e. the path to the ASP file that is currently executing. It would have been easier to do Dir = Left(Dir, InstrRev(Dir, "/"))<BR><BR>Path = Server.MapPath(Dir) & "\"<BR><BR>Convert to physical path on the server.<BR><BR>f = "ms_access.dsn"<BR>DSN = "filedsn=" & Path & f & ";DefaultDir=" & Path & ";DBQ=" & Path & DB & ";"<BR><BR>The DSN details are stored in a file called ms_access.dsn which is in the same folder as the ASP page that&#039;s being executed.<BR><BR>Set con = Server.CreateObject("ADODB.Connection")<BR>con.Ope n DSN<BR>End Sub<BR><BR>Well, the rest is obvious. Just open the connection using the DSN.<BR><BR>I think if you open the .dsn file you&#039;ll be able to see where the database is actually stored and then point to that in your code. I assume you know how to open a recordset without DSN.<BR><BR>Oliver.

Posting Permissions

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