Results 1 to 6 of 6

Thread: Help! Connecting to SQL via ASP

  1. #1

    Thread Starter
    Hyperactive Member parkes's Avatar
    Join Date
    Jan 1999
    Location
    Unitied Kingdom
    Posts
    303
    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?
    Thanks in advance for any help provided.

    VB 6 Enterprise Edition SP4
    ADO, SQL 7/2000, ASP and some JavaScript


    >> Life goes on, but for how long? <<
    If you can smile when things go wrong, you have someone in mind to blame

  2. #2
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    #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.

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    monte96_@hotmail.com
    monte96@vbgarage.com


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

  3. #3
    Lively Member
    Join Date
    May 2000
    Location
    Canada
    Posts
    70

    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

    ...
    %>


  4. #4
    New Member
    Join Date
    Oct 2000
    Posts
    3
    Check carfully if the error not form kod of your client...
    it seems like en error of client not of asp kod .

  5. #5
    Guest

    Cool

    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.

  6. #6
    Frenzied Member monte96's Avatar
    Join Date
    Sep 2000
    Location
    Somewhere in AZ
    Posts
    1,379
    That actually sound like the most likely culprit...

    oOOo--oOOo
    __/\/\onte96
    oOOo--oOOo
    Senior Programmer/Analyst
    MCP
    monte96_@hotmail.com
    monte96@vbgarage.com


    Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..

Posting Permissions

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



Click Here to Expand Forum to Full Width