-
I'm trying to connect to a SQL 7 database via an ASP page, but having not luck. I just keep getting this error
Microsoft VBScript runtime error '800a01ad'
ActiveX component can't create object
I've created the System DSN file and it works okay. The code I use to try and make a connection is
<%
Set dbase=Server.CreateObject("ADODB.Connection")
dbase.Open "WebCts2000"
%>
but it doesn't work any ideas?
-
#1, take note of which line is failing when you get that error message. (may not be the one your expecting)
#2, Your connection string should have "DSN=WebCts2000;uid=username;pwd=password"
You have to specify the username and password, the userid can be saved in the DSN but not the PW.
-
This is works for me:
<%
OPTION EXPLICIT
Response.Buffer = true
Server.ScriptTimeOut =360
%>
<!-- #include file="./Include/Constants.asp" -->
<%
Private Sql, ConnString
Private Conn, Cmd, RS
Private blnOpen
ConnString = "Provider=SQLOLEDB.1;" & _
"Persist Security Info=False;User ID=UserID;" & _
"Initial Catalog=DBName;Data Source=SQLServerName"
sql = "Select blah from tblBlah"
Set Conn = Server.CreateObject("ADODB.Connection")
Set Cmd = Server.CreateObject("ADODB.Command")
Set RS = Server.CreateObject("ADODB.Recordset")
Conn.ConnectionTimeout = 180
Conn.Mode = adModeShareDenyNone
Conn.CursorLocation = adUseClient
Cmd.CommandTimeout = 180
Cmd.CommandType = adCmdText
RS.CursorType = adOpenDynamic
RS.CursorLocation = adUseServer
RS.LockType = adLockOptimistic
Conn.Open ConnString
Set Cmd.ActiveConnection = Conn
Cmd.CommandText = Sql
Set RS.ActiveConnection = Conn
RS.Open Cmd
if err.number <> 0 then
Call Err_Create(err.number, err.description, err.source)
call DestroyObjects
else
blnOpen = True
blnFirstRec = TRUE
end if
if ((RS.eof) OR (not blnOpen)) then
response.write "<BR><CENTER><B>No Records Found " & _
"</B></CENTER><BR>"
else
RS.movefirst
...
Private Sub DestroyObjects
RS.Close
Conn.Close
Set RS = Nothing
Set Cmd = Nothing
Set Conn = Nothing
End Sub
...
%>
-
Check carfully if the error not form kod of your client...
it seems like en error of client not of asp kod .
-
You might make sure MDAC is installed on the server, you can't make an ADO connection without it, it can be downloaded from http://www.microsoft.com/downloads if you don't have it.
-
That actually sound like the most likely culprit...