Re: Really tough ADO Stored Procedure Question. Please Help!!!

From: Scott (js_at_tds.net)
Date: 08/26/04


Date: Wed, 25 Aug 2004 22:15:33 -0400

Check to be sure you are connecting to the database via VB using the SAME
LOGON id as what you connected via Sql Analyzer. If your logon/permissions
are different, you could be hitting an error related to permissions and not
know it. The best way to find out if that is happening is to use the
Connection Objectss "Errors CVollection" in your VB. I didnt see any
mention of that, so here's a snippet of code to help you with that if you
need....

function Get_Child_Recs_Tools (msg, key)
 '
 ' This proc gets a row count from the
 ' T_EQP_Tools table where fab_id = the key
 ' of fab_id of the T_EQP_Tools row that is
 ' about to be deleted.
 ' Any row count greater than 0 results in failure.

 on error resume next

 Get_Child_Recs_Tools = "NotOk"

 tbl_primkey = cint(key)
 sql_get = " Select Count(*) counter from TBLFAB where fabname = "
 sql_get = sql_get & tbl_primkey

 set cn = Server.CreateObject("ADODB.Connection")
 cn.open str_Connect
 set rs = Server.CreateObject("ADODB.Recordset")
 rs.open sql_get, cn, adOpenForwardOnly
 rs.movefirst

 txt_rowcount = rs("counter")

 if cn.Errors.Count > 0 then
  Rtnmsg = ""
  For each Error in cn.errors
   Rtnmsg = Rtnmsg & "Error # : " & Error.Number & ", "
   Rtnmsg = Rtnmsg & "Error Description : " & Error.Description
  Next
  cn.Errors.Clear
 else
  if txt_rowcount = 0 then
   Get_Child_Recs_Tools = "Ok"
  end if
 end if

end function

P.S. I snipped this from an ASP application, so you'll have to cut out the
"Server." keyword from the ADO Object references and maybe make a few other
touchups.....

g'Luck

"Ian" <ian@NoWhere.com> wrote in message
news:OVPudKdhEHA.3476@tk2msftngp13.phx.gbl...
>
> Hi
>
> I was hopping some one can give me an explanation for this.
>
> Stored Procedure: (All this is in one stored procedure but this is the
> basis
> of what it does)
>
> Step 1: I have a stored procedure that selects some records from
> tblTableOne
> into #Temp1.
> Step 2: It then goes to and excel workbook and gets some data and holds
> that
> in a #Temp2.
> Step 3: Then I run an update statement on #Temp1 using the data in
#Temp2.
> Step 4: Once this is done I then Insert the data from #Temp1 back into
> tblTableOne as new records.
>
>
> Scenario:
>
> When running in debug mode in Query Analyser the stored procedure works
> perfectly.
> When I then check the data it has all been accurately updated and
inserted
> back into tblTableOne.
>
> When I run the Stored procedure from using the "exec sp_Name" it works
> perfectly also.
>
> BUT.
>
> When I run the Stored procedure from my VB 6 application at first glance
it
> seems to work fine in the fact that there is no errors and when the data
is
> checked it is there.
> However the data has not been changed to the Data in #Temp2. So something
> is
> going wrong with Step 2 or 3.
>
> So I then added an output parameter to the SP to check that there was
data
> being imported form Excel and there were the correct no of records. and
> there are.
>
> So that has now narrowed it down to Step 3. Since it works fine from
Query
> Analyser and no errors are being thorn by the stored procedure. I have
also
> added Error handling just after the UPDATE statement and there is no
error
> in @@ERROR.
>
> I have been battling with this for about 12 hours now.
>
> Please any thing that I could try would be welcome.
>
> I have been trying different database option but no luck. Maybe I am
> setting
> them incorrectly or in the wrong place.
>
> My guess is that I think that just that one UPDATE statement is rolling
> back.
> It doesn't sound possible I know, but I am watching it.
>
> I have tried creating a transaction inside the SP and I have also tried
> creating a transaction for the database connection using ADO. and still
no
> joy.
>
> I know it is a tough one.
>
> I am willing to email the SP and sample data it your up for a challenge.
>
> Thanks
>
> Ian
>
>
>
>
>
>
>
>
>



Relevant Pages

  • Re: Really tough ADO Stored Procedure Question. Please Help!!!
    ... Check to be sure you are connecting to the database via VB using the SAME ... Connection Objectss "Errors CVollection" in your VB. ... > Stored Procedure: (All this is in one stored procedure but this is the ... > in a #Temp2. ...
    (microsoft.public.sqlserver.odbc)
  • Connection issues
    ... Each user connected to the server has their own connection ... to the database. ... stored procedure we call is returning null(No, not DBNull, but actual ... we kill their connection through enterprise manager. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: sp_attach_db
    ... Calling the stored procedure is not an asynchronous action, ... database to your attached database if the action succeeded. ... successful or not - 0 for success and 1 for failure. ... > and then try to open the connection within the same ...
    (microsoft.public.sqlserver.msde)
  • Re: OLEDB Session Error
    ... ConnectionInfo that stores information about the database, server, user, ... However, when I did the same before attempting the connection, all ... I am executing this stored procedure from an application written ...
    (microsoft.public.data.oledb)
  • Re: ADO Connection Timeout
    ... so what happens when a connection failure forces one station to revert ... to a local database? ... Further, you *will* have contention issues, Jet does not support record ... to the central server, but you are willing to live with periods where it ...
    (microsoft.public.data.ado)

Loading