herba98
08-12-2004, 03:24 PM
Hello, Im new with ASP and need to connect with a ODBC database, can you help me with a basic syntax to use?
thanks
thanks
|
Click to See Complete Forum and Search --> : connect with ODBC herba98 08-12-2004, 03:24 PM Hello, Im new with ASP and need to connect with a ODBC database, can you help me with a basic syntax to use? thanks buntine 08-12-2004, 08:05 PM www.asp101.com has several good examples in the samples section. You must create an ADO connection object and a connection string, which tells ADO where the database is and which driver you want to use. Dim objConn, strConn Set objConn = Server.CreateObject("ADODB.Connection") strConn = "DBQ=" & Server.MapPath("subdir\yourDatabase.mdb") & ";" & _ "Driver={Microsoft Access Driver (*.mdb)}" objConn.open(strConn) That should open a connection to an MS Access database. To use other ODBC capable database's, you will need to look on asp101 for the correct connection strings. Regards, Andrew Buntine. peachy 08-12-2004, 11:24 PM If you have several ASP pages you can save your connection string in a separate ASP. Then on your other ASP pages just put: <%@ Language=VBScript %> <!--#include file="connstring.asp"--> The "connstring.asp" being the ASP with the connection string,it will look at the "connstring.asp" for the information to do the connection. Then if you do need to change the connection string you only have to change it on the one ASP verses changing each page. I found this VERY handy.:) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |