ServersFile DSN's Page 3

File DSN’s Page 3

ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.




To use the file DSN is as simple as building a connection string
giving the file DSN name and building the database source.

‘First create the connection
object

Set oconnect =
Server.CreateObject(“ADODB.Connection”)

‘Next I map a path to a virtual directory containing
all my databases
‘This saves time moving the application from a
local to a remote server, the
‘Physical paths can change, but
the virtaul remain the same. Server.MapPath returns
‘A physical
path from a virtual directory.
DB_PATH =
SERVER.MAPPATH(“/DATABASE”)

‘Next build
a connection string using the file DSN we created and
‘The mapped
path to the database directory with the database we want to connect
to

CONNECT_STR = “FILEDSN=WEB.DSN;” & _

                
“DBQ=” & DB_PATH & “WEBDB.MDB;”

‘Now connect as normal and your
done

oconnect.Open CONNECT_STR

That’s all there is to it!

Get the Free Newsletter!

Subscribe to Daily Tech Insider for top news, trends & analysis

Latest Posts

Related Stories