VBScript MS Access Database Connection


/ Published in: ASP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. '****************************************
  2. ' VBScript MS Access database connection
  3. '****************************************
  4.  
  5. dim strConn, objConn, sql, rst
  6.  
  7. if lcase(Request.ServerVariables("SERVER_NAME")) = "localhost" then
  8. strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\inetpub\wwwroot\mysite\db.mdb;"
  9. else
  10. strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath("/") & "\db.mdb;"
  11. end if
  12.  
  13. set objConn = server.createobject("adodb.connection")
  14. objConn.open strConn

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.