DSNless Conncection as a Variable

Results 1 to 2 of 2

Thread: DSNless Conncection as a Variable

  1. #1
    Join Date
    Dec 1969

    Default DSNless Conncection as a Variable

    I can successfully create a DSNless connection, but I would like to use a variable for the connection string so that I can move this ASP file from server to server without having to type in a new DB connection string each time. The variable (ConnString) looks properly, but the ConnectionString won&#039t read it has a proper string.<BR><BR>My ASP file looks like this:<BR><BR>&#060;%<BR><BR>DBpath = server.mappath("temps.mdb")<BR>DriverString = "DRIVER={Microsoft Access Driver (*.mdb)}"<BR>ConnString = (Chr(34)) & "DBQ=" & DBpath & ";" & DriverString & (Chr(34))<BR><BR>Dim objConnSet objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .ConnectionString = ConnString<BR>objConn.Open<BR><BR>objConn.Close<BR >objConn = Nothing<BR><BR>%&#062;<BR>

  2. #2
    peterjl@austec.net.au Guest

    Default RE: DSNless Conncection as a Variable

    Your code seems t assume that the database file is in the same folder as the ASP file. This seems fine as long as the folder permission does not allow http access to the database file.<BR><BR>With this setup you can move you asp file an db to any server and it will work as long as they are together.<BR><BR>If you want to separate the two files, you should put the db into some standard folder and then you would put the db into that folder on whatever server you use. The path should be relative to the vertiual root dir. Then your dbpath would be like "/mydata/temp.mdb". If you make the path relative you will have to maintain the relativity and your path will vary if you move the ASP to another folder.

Posting Permissions

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