Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: SQL sp called from VB doesn't return control to VB code


Message #1 by "Vlada Bromberg" <Vlada@d...> on Wed, 4 Dec 2002 11:15:53 -0500
Hi everybody,
I have a strange problem.

My VB code builds connection to SQL server and executes Stored 
Procedure. Then it should print Access report. On my machine it runs OK. 
(I have Visual Studio Enterprise edition and local SQL server connected 
to the server SQL). When I deployed the code to a user computer it runs 
just the first part (executes stored procedure on the Server) and kicks 
out without giving any error messages. I tried to split the code into 2 
parts  - SQL and Access - and run them separately. It worked fine!
As I understand it gets lost on the SQL server.
Do you have any suggestions how I can fix this problem?

Here is my code:

Sub Main()

Dim cnSBS As Connection
Dim rsUpdateInvent As ADODB.Recordset

On Error GoTo err_handler

    'execute stored procedure
    Set cnSBS =3D New Connection
    cnSBS.Open "Provider=3DSQLOLEDB.1;Persist Security Info=3DFalse;" & 
_
                 "User ID=3Dsa;Initial Catalog=3DInventoryControl;" & _
                 "Data Source=3DSBS"
    cnSBS.CursorLocation =3D adUseServer

   
    Set rsUpdateInvent =3D cnSBS.Execute("sp_UpdateEndInventory", , _
                                            adCmdStoredProc)
                                           
    DoEvents
    Set rsUpdateInvent =3D Nothing
    Set cnSBS =3D Nothing
  
    'I included the next line for the response control. The message box 
never pops up.
    MsgBox "Now print report"
   
   'print Access Report
    Call PrintReport
   
err_exit:
    Exit Sub
err_handler:
    MsgBox Err.Number & " - " & Err.Description
    Resume err_exit
End Sub



Sub PrintReport()

    Dim DottiD As Access.Application
    Dim strPath As String

    On Error GoTo err_handler

    Set DottiD =3D New Access.Application

    strPath =3D App.Path & "\DottiDillard.mdb"
   
    DottiD.Visible =3D False
    DottiD.OpenCurrentDatabase (strPath)

    'Print report
    DottiD.DoCmd.OpenReport "rptDottieDillard", acViewNormal
    DoEvents
    DottiD.Quit
   
    Set DottiD =3D Nothing
err_exit:
    Exit Sub
err_handler:
    MsgBox Err.Number & " - " & Err.Description
    Resume err_exit
End Sub

  Return to Index