Problem using Stored procedures

Discussion in 'Databases' started by donobugc, Apr 5, 2010.

  1. donobugc

    donobugc Programming since 1963

    Connecting to database here at Winhost:


    Dim conn

    conn = "Provider=SQLOLEDB;Data Source=s01.Winhost.com;" _
    & "Initial Catalog=Databasename;" _
    & "User Id=Userid;Password=password;" _
    & "Connect Timeout=15;" _
    & "Network Library=dbmssocn;"​

    Then, when I want to access a database table, I do something like this:

    myWork.Open qryWork, conn, adOpenForwardOnly, adLockReadOnly, adCmdText​

    At work, where I use SQL Server 2005 and have a dedicated DBA,
    I don't have to use the Network Library=dbmssocn; section.

    At work, when I use a Stored procedure, I just use:

    Set cmdStoredproc = Server.CreateObject("ADODB.Command")
    Set cmdStoredproc.ActiveConnection = conn
    cmdStoredproc.CommandText = "Wordwheel"
    cmdStoredproc.CommandType = adCmdStoredProc
    cmdStoredproc.CommandTimeout = 60
    cmdStoredproc.Parameters.Refresh

    When I do this at Winhost, I get the following:

    Microsoft VBScript runtime error '800a01a8'
    Object required: 'ActiveConnection'​
    Can someone tell me what I need to do to be able to execute this Stored Procedure?

    Thanks in advance,

    Mike:confused:
     
    Last edited by a moderator: Oct 14, 2015
  2. Ray

    Ray

    Try removing this line..

    Network Library=dbmssocn

    ...from your code.
     
  3. donobugc

    donobugc Programming since 1963

    Removing Sockets oesn't work

    This didn't work any better. It is the same problem. It made no difference.

    When I first tried to connect to my database when I first got Winhost in December, I wasn't able to connect over the web. I emailed support@Winhost and they sent me that connection string. I can now access my database. Their solution added that Network Library string. So it has to be something else.

    I can connect using SQL Server Management Studio and run the SP, so I know that the problem is not there.

    Any other thoughts? Anyone?
     
    Last edited by a moderator: Oct 14, 2015
  4. Ray

    Ray

    Do you have a URL we can use to see the error message ourselves?
     
  5. donobugc

    donobugc Programming since 1963

    If you go to this URL:

    And type something into the Author box, you'll get the error. I have tried with and without the

    "Network Library=dbmssocn;"​

    Line you suggested I remove.

    Is there anyone out there executing SQL Server Stored Procedures using VBScript?

    Mike Donovan
     
  6. Ray

    Ray

    Your website is a PHP application. I do not think we have the SQL Native drivers for PHP installed on the server.
     
  7. donobugc

    donobugc Programming since 1963

    PHP application? Since when?

    It is pure and simple Active Server Pages (asp). I wrote the whole application in VBScript. I do this for a living developing web applications which access SQL Server databases.
     
  8. Ray

    Ray

    Sorry, I must have pulled up another site.

    Did you declare the ADO connection correctly?

    Did you set..

    cmdStoredproc Server.CreateObject("ADODB.Connection")

    I quickly tested your account, by uploading an asp test script called Winhosttest.asp in your root. It connected to the database just fine with out any errors.

    http://donobug.com/Winhosttest.asp
     
    Last edited by a moderator: Oct 14, 2015
  9. donobugc

    donobugc Programming since 1963

    My first post gave all the things I did. And yes, I did declare the and open the ADO connection. Please look at the first post.

    Someone from Winhost gave me a script before but he called it testdbWinhost.asp. But that was in December last year.
     
    Last edited by a moderator: Oct 14, 2015
  10. Ray

    Ray

    Have you checked your code?

    Look at the line of the error it is telling you..

    Object required: ''

    /$webapp/wordwheel.asp, line 48

    Have you checked this line?

    If you checked this line it will point to..

    ConnSp.Open ConnSPstr


    Did you check how you decalred it?

    On your code you have...

    Dim connSPstr

    Try making sure you have a line typed

    Set connSPstr = Server.CreateObject("ADODB.Connection")

    The best thing to do is set up a simple ASP script as a test for you. Troubleshooting the connection string on your web application can be daunting and confusing and it is better to test from a smaller piece of code then doing it from a larger pieice of cod. Look at this kb article again. Copy and paste it exactly as it is only modifying the values on the connection string and the query it performs. From there once it works, study the steps it is taking to connect to the SQL server and then you can apply that to your application to help fix it and get it to start working.
     
  11. donobugc

    donobugc Programming since 1963

    The error that you pointed out is the result of my trying to get something to work since I have gotten no help from anyone. I put the code back to the way it was originally. It now gets the original error. Object Required: 'ActiveConnection'.

    It is obvious that you have looked at my code. You don't need to ask me if I did a:

    Set connSPstr = Server.CreateObject("ADODB.Connection")

    You can see that I did.

    What kb article are you referring to? I don't seem to see any reference to any kb articles in any of the posts.
     
  12. Ray

    Ray

    Last edited by a moderator: Oct 14, 2015
  13. donobugc

    donobugc Programming since 1963

    YOU just don't seem to understand. I can query the database. I just cannot execute a Stored Procedure....
     
  14. Ray

    Ray

    So this is no longer the error message you are getting?

    Microsoft VBScript runtime error '800a01a8'
    Object required: 'ActiveConnection'

    This error message is specific to a database connection.

    Do you have a new error message? Have you tried running the stored procedure on your SSMS to see if it will run?
     
  15. donobugc

    donobugc Programming since 1963

    problem solved

    For those who are interested in actually calling a Stored Procedure, the code below actually works. Am I the only one doing any SQL Server database programming on Winhost?

    This code is almost identical to the code I originally posted. The only problem might have been on the line in Red below. I had to remove the set part of the statement

    Set conn = Server.CreateObject("ADODB.Connection")
    conn.Open ConnSPstr

    Set cmdStoredproc = Server.CreateObject("ADODB.Command")
    cmdStoredproc.ActiveConnection = connSPstr
    cmdStoredproc.CommandText = "Wordwheel"
    cmdStoredproc.CommandType = adCmdStoredProc
    cmdStoredproc.CommandTimeout = 60
    cmdStoredproc.Parameters.Refresh
     

Share This Page