Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using DAO to Run Stored Procedures

Status
Not open for further replies.

dellyjm

Programmer
Apr 13, 2000
168
JM
How do I use DAO to run a Stored Procedure?>
 
In my knowledge DAO does not support SP. You have to use ADO to use SP method with its high performence and scalibity.
 
If I am correct, SP only works on SQL Server, and from what I Also know DAO doesnt support SQL Server(only Jet Databases) where as ADO supports any ODBC supported databases(through ODBC drivers), I have a FAQ on ADO if you want to see a gernal example of its usage. <p>Karl<br><a href=mailto:kb244@kb244.8m.com>kb244@kb244.8m.com</a><br><a href= </a><br>Experienced in , or have messed with : VC++, Borland C++ Builder, VJ++6(starting),VB-Dos, VB1 thru VB6, Delphi 3 pro, Borland C++ 3(DOS), Borland C++ 4.5, HTML,Visual InterDev 6, ASP(WebProgramming), QBasic(least i didnt start with COBOL)
 
I found a solution guys, had to switch my program from DAO to ADO though, see solution below.<br><br>One other problem I was having why I wasn't being successful was that some tables weren't populated on the SQL Server database which the stored procedure was calling<br>so it would bomb out...thanx again guys.<br><br>Function StoredProc(gdate As String)<br><br>On Error GoTo ErrorHandler<br><br>Conn.BeginTrans<br>With Comm<br>&nbsp;&nbsp;&nbsp;.CommandText = &quot;sp_rmvnull_inv&quot;<br>&nbsp;&nbsp;&nbsp;.CommandType = adCmdStoredProc 'a constant<br>&nbsp;&nbsp;&nbsp;.ActiveConnection = Conn<br>&nbsp;&nbsp;&nbsp;.Execute ' execute the stores procedure.<br>End With<br>With Comm<br>&nbsp;&nbsp;&nbsp;.CommandText = &quot;sp_run_invoices&quot;<br>&nbsp;&nbsp;&nbsp;.CommandType = adCmdStoredProc 'a constant<br>&nbsp;&nbsp;&nbsp;.ActiveConnection = Conn<br>&nbsp;&nbsp;&nbsp;.Parameters.Refresh<br>&nbsp;&nbsp;&nbsp;.Parameters(&quot;@pub_date&quot;).Value = gdate<br>&nbsp;&nbsp;&nbsp;.Parameters(&quot;@pub_date&quot;).Direction = adParamInput<br>&nbsp;&nbsp;&nbsp;.Execute ' execute the stores procedure.<br>End With<br>Conn.CommitTrans<br><br>bDBConnectFail = False<br><br>Exit Function<br><br>ErrorHandler:<br><br>Conn.RollbackTrans<br>bDBConnectFail = True<br><br>End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top