ASP database connect string

Results 1 to 4 of 4

Thread: ASP database connect string

  1. #1
    Paul Hudson Guest

    Default ASP database connect string

    This code was produced by using IDC2ASP:<BR><BR>&#060;%@ LANGUAGE="VBScript" &#037;&#062;<BR>&#060;!--#include file="ADOVBS.inc"--><BR>&#060;!--#include file="IASUtil.asp"--><BR><BR>&#060;%<BR> Set Connection = Server.CreateObject("ADODB.Connection")<BR> <BR> Connection.Open "DSN=Courses"<BR><BR> SQLStmt = "SELECT COURSE_TITLE, "<BR> SQLStmt = SQLStmt & "COURSE_CODE, "<BR> SQLStmt = SQLStmt & "LOCATION, "<BR> SQLStmt = SQLStmt & "START_DATE, "<BR> SQLStmt = SQLStmt & "END_DATE, "<BR> SQLStmt = SQLStmt & "START_TIME, "<BR> SQLStmt = SQLStmt & "END_TIME, "<BR> SQLStmt = SQLStmt & "LEAFLET, "<BR> SQLStmt = SQLStmt & "DAYS, "<BR> SQLStmt = SQLStmt & "PLACES_LEFT "<BR> SQLStmt = SQLStmt & "FROM t_courses "<BR> SQLStmt = SQLStmt & "ORDER BY COURSE_TITLE, COURSE_CODE; "<BR><BR> Set RS = Connection.Execute(SQLStmt)<BR>&#037;&#062;<BR><BR >...before the &#060;html> tag. What have I got to change or add to enable connection to the database without using ODBC?<BR><BR>Many thanks, Paul.<BR><BR>

  2. #2
    Paul Hudson Guest

    Default RE: ASP database connect string

    Sorry, this may be in the wrong group.

  3. #3
    Join Date
    Dec 1969
    Posts
    168

    Default RE: ASP database connect string

    If this is an access database... you can use the following to do a DNS-less connection<BR><BR>&#060;%@ LANGUAGE="VBScript" &#037;&#062;<BR>&#060;!--#include file="ADOVBS.inc"--><BR>&#060;!--#include file="IASUtil.asp"--><BR>&#060;%<BR>Dim DB_CONN_STRING<BR>DB_CONN_STRING = "DBQ=" & Server.MapPath("yourdb.mdb") & ";"<BR>DB_CONN_STRING = DB_CONN_STRING & "Driver={Microsoft Access Driver (*.mdb)};"<BR>DB_CONN_STRING = DB_CONN_STRING & "DriverId=25;FIL=MS Access;"<BR><BR>QLStmt = "SELECT COURSE_TITLE, "<BR>SQLStmt = SQLStmt & "COURSE_CODE, "<BR>SQLStmt = SQLStmt & "LOCATION, "<BR>SQLStmt = SQLStmt & "START_DATE, "<BR>SQLStmt = SQLStmt & "END_DATE, "<BR>SQLStmt = SQLStmt & "START_TIME, "<BR>SQLStmt = SQLStmt & "END_TIME, "<BR>SQLStmt = SQLStmt & "LEAFLET, "<BR>SQLStmt = SQLStmt & "DAYS, "<BR>SQLStmt = SQLStmt & "PLACES_LEFT "<BR>SQLStmt = SQLStmt & "FROM t_courses "<BR>SQLStmt = SQLStmt & "ORDER BY COURSE_TITLE, COURSE_CODE; "<BR><BR>Set cnn = Server.CreateObject("ADODB.Connection")<BR>cnn.Ope n DB_CONN_STRING<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR>rs.Open SQLStmt, cnn<BR><BR>On Error Resume Next<BR>rs.MoveFirst<BR>do while Not rs.eof<BR>&#037;&#062;<BR><BR>...do what you want with the recordset ie html...<BR><BR>&#060;%<BR>rs.MoveNext<BR>loop<BR>& #037;&#062;<BR><BR>&#060;%<BR>rs.Close<BR>Set rs = Nothing<BR>cnn.Close<BR>Set cnn = Nothing<BR>&#037;&#062;<BR><BR>Hope this helps... Cheers!

  4. #4
    Paul Hudson Guest

    Default RE: ASP database connect string

    Works like a dream, many thanks.


Posting Permissions

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