executing stored procedures in vb

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rvdw

    executing stored procedures in vb

    Hi All,

    I've a serious problem with executing stored procedures (SQL2000) from
    an Access db (version 97). After executing a stored procedure ,
    msaccess hangs. The whole call to the procedure is running fine, but
    immediatly after this msaccess hangs, when the focus goes back to the
    calling form ?
    Has anyone any idea what i can test or look at.

    Thanks a lot !!!!!!



    CODE*********** **


    Function DownloadData() 'This is the function executed when clicking
    on a btn on form
    Dim RetVal

    RetVal = Execute_Procedu re("sp_Download Data", "", False)
    MsgBox "All data has been downloaded "
    'UNTIL EVERYTHING IS WORKING FINE BUT WHEN GOING OUT THIS FUNTION
    THE ACCESS APPLICATION START USING 100% CPU AND HANGS

    End Function




    Public Function Execute_Procedu re(iProcedure As String, iArgs As
    String, iIndicator As Boolean) As Boolean


    Dim t1, t2
    t1 = Timer

    DoCmd.Echo False, "Executing procedure " & iProcedure & " " &
    iArgs


    Dim oCn As ADODB.Connectio n
    Set oCn = New ADODB.Connectio n

    oCn.ConnectionS tring = gCn
    oCn.Open
    oCn.CommandTime out = 0

    Dim oCmd As ADODB.Command
    Set oCmd = New ADODB.Command

    oCmd.CommandTim eout = 0
    oCmd.CommandTyp e = adCmdStoredProc

    oCmd.CommandTex t = iProcedure & iArgs

    oCmd.ActiveConn ection = oCn

    oCmd.Execute , , adExecuteNoReco rds

    oCn.Close

    t2 = Timer

    DoCmd.Echo False, iProcedure & " executed in " & CInt((t2 - t1)) &
    " seconds"

    Set oCmd = Nothing
    Set oCn = Nothing

    Execute_Procedu re = True

    End Function
Working...