DSN-less with .inc file

Results 1 to 2 of 2

Thread: DSN-less with .inc file

  1. #1
    Join Date
    Dec 1969

    Default DSN-less with .inc file

    My brother, who is a much better programmer than I, uses a DSN-less connection by using 2 .inc files.<BR><BR>One called, bas.inc has this in it:<BR><BR>dbName="mydatabase.mdb"<BR><BR>The other called, adb.inc has this:<BR><BR>set my_conn= Server.CreateObject("ADODB.Connection")<BR>my_Conn .Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" + dbf<BR><BR>His statement on the page then reads something like this:<BR><BR>&#060;!-- #include file="bas.inc" --&#062;<BR><BR>dbf=Server.MapPath (dbName)<BR><BR>set my_conn= Server.CreateObject("ADODB.Connection")<BR>my_Conn .Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" + dbf<BR><BR>He&#039s not around for me to ask so I am asking here. What the heck is the difference between what he does and this? It doesn&#039t even look like he calls the other file adb.inc. <BR><BR> Dim Conn, dbPath<BR> dbPath = "e:virtualhostsmyurl.comwwwmydatamydatabase.md b "<BR> Set Conn = Server.CreateObject("ADODB.Connection")<BR> Conn.Open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=" & dbPath<BR><BR>They are both DSN-less connection but his seems much more involved. Why?

  2. #2
    Join Date
    Dec 1969

    Default RE: DSN-less with .inc file

    In my opinion, your connection string is actually better. It looks to me as though your brother is using a shortcut by not specifying the provider (I guess you get msdasql if you don&#039t specify anything) and he&#039s also using + as a concatenation operator (legal but not preferable). The two providers have slightly different functionality - you&#039ll have to try them both to see which works better in your application. If you use the oledb provider for odbc drivers (msdasql), you have to specify a driver as well. That may be why his string appears more involved than yours.

Posting Permissions

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