View Full Version : just a question
Hello!
I just want to ask you which is the best way to connect to my DB?
i usually use a DSN connection like this:
---------------
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSN=RHDSN;"
Set rs = Server.CreateObject("ADODB.Recordset")
SQLStmt = "SELECT * FROM REGISTOS"
rs.Open SQLstmt,Conn,1,2
---------------
i've heard that the OLEDB connections are better. is this true? in what way are they better? which kind of OLEDB connection should i use? Is this the best type of connection or is there another one?
Roy Sinclair
02-19-2004, 02:41 PM
This article should help:
http://www.4guysfromrolla.com/webtech/063099-1.shtml
thanks for replying.
i just tested the OLEDB and it works fine. had a little trouble because my db was on a server and i had to access it. OLEDB doesn't allow the use of URLs so used used UNCs instead.
for anyone interested here is the code i used:
-------------------------------------
Set Conn = Server.CreateObject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.OLEDB.4.0;" &_
"Data Source=\\servername\servershare\myDB.mdb;" &_
"User Id=admin;" &_
"Password="
Set rs = Server.CreateObject("ADODB.Recordset")
SQLStmt = "SELECT * FROM Temas"
SET RS = Conn.Execute(SQLStmt)
-------------------------------------------
Bullschmidt
02-24-2004, 04:23 AM
Just a minor point but one nice thing about DSN's is that there is little chance that an error message will reveal the path to the DB (which would probably be outside the www anyway of course).
Originally posted by Bullschmidt
Just a minor point but one nice thing about DSN's is that there is little chance that an error message will reveal the path to the DB (which would probably be outside the www anyway of course).
Hmm. But that doesn't realy compensate for the downsides:
- slower to connect;
- fixed adress --> less portable, even on the same machine
- requires intervention of your host;
and i even think you can prevent leaking through errormessages by turning them to 'userfriendly errormessages' or so (don't have IIS here) or including your own erropages.
DSN-less connections are definitely the way to go.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.