Calling a SQL Server 2000 store procedure from MS-Access 
Author Message
 Calling a SQL Server 2000 store procedure from MS-Access

Hi!

Somebody could give me a sample code to execute an store procedure on a SQL
Server 2000 database from an MS-Access 2000?

The Store Procedure has a parameter, and I need to call it from a VBA
function

Thanks!



Sat, 08 May 2004 07:14:12 GMT  
 Calling a SQL Server 2000 store procedure from MS-Access
Hi Andrs,

You don't say if ADP or MDB

Example for ADP and ADO

Dim cmd As New ADODB.Command
Dim prm As ADODB.Parameter

With cmd
    .ActiveConnection = CurrentProject.Connection
    .CommandText = "dbo.myStoredProc"
    .CommandType = adCmdStoredProc

    ' First a sample to bind a parameter for a
    ' return-value to the command-object
    Set Prm = cmd.CreateParameter("Return", adBigInt,
adParamReturnValue)
    cmd.Parameters.Appnd prm

    ' This sample is for binding a char-var as a
    ' parameter to the command-object
    Set prm = cmd.CreateParameter("MyVar", adVarChar, adParamInput,
Len('MyVar'), 'MyVar')
    cmd.Parameters.Append prm

    ' Now we fire the stored procedure
    .Execute

    ' ... and see, what is the return-value of the sp
    MsgBox .Parameters("Return")
End With

' Now destroy the objects
Set cmd = Nothing
Set prm = Nothing

HTH :-)

--
Gru?, Uwe Ricken
MCP FOR MS ACCESS DEVELOPMENT
GNS GmbH, Frankfurt am Main
http://www.gns-online.de
____________________________________________________
APP:    http://www.AccessProfiPool.com
FAQ:   http://www.donkarl.com/AccessFAQ.htm



Sat, 08 May 2004 13:34:39 GMT  
 Calling a SQL Server 2000 store procedure from MS-Access
Sorry not right e-mail box leave me out of your next question, have not a
clue why I am getting these messages.



Quote:
> Hi!

> Somebody could give me a sample code to execute an store procedure on a SQL
> Server 2000 database from an MS-Access 2000?

> The Store Procedure has a parameter, and I need to call it from a VBA
> function

> Thanks!




Sun, 09 May 2004 00:26:16 GMT  
 Calling a SQL Server 2000 store procedure from MS-Access
And how does this look like for an ".mdb"-Database?
I try to run a Stored Procedure on a SQL-Server 7 which returns a Resultset,
using one parameter:
Quote:
>Alter Procedure PROZ_qryBanken_OrderByBezeichnung


As

SELECT *

FROM dbo.Banken


ORDER BY K_Bank_L1, K_Ort return

<


want to use the Resultset as "Me.recordset" for an userform.

any suggestions?

mfg

Dirk Ortmann



Quote:
> Hi Andrs,

> You don't say if ADP or MDB

> Example for ADP and ADO

> Dim cmd As New ADODB.Command
> Dim prm As ADODB.Parameter

> With cmd
>     .ActiveConnection = CurrentProject.Connection
>     .CommandText = "dbo.myStoredProc"
>     .CommandType = adCmdStoredProc

>     ' First a sample to bind a parameter for a
>     ' return-value to the command-object
>     Set Prm = cmd.CreateParameter("Return", adBigInt,
> adParamReturnValue)
>     cmd.Parameters.Appnd prm

>     ' This sample is for binding a char-var as a
>     ' parameter to the command-object
>     Set prm = cmd.CreateParameter("MyVar", adVarChar, adParamInput,
> Len('MyVar'), 'MyVar')
>     cmd.Parameters.Append prm

>     ' Now we fire the stored procedure
>     .Execute

>     ' ... and see, what is the return-value of the sp
>     MsgBox .Parameters("Return")
> End With

> ' Now destroy the objects
> Set cmd = Nothing
> Set prm = Nothing

> HTH :-)

> --
> Gru?, Uwe Ricken
> MCP FOR MS ACCESS DEVELOPMENT
> GNS GmbH, Frankfurt am Main
> http://www.gns-online.de
> ____________________________________________________
> APP:    http://www.AccessProfiPool.com
> FAQ:   http://www.donkarl.com/AccessFAQ.htm



Fri, 14 May 2004 23:09:30 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Executing MS SQL Server 2000 stored procs via MS Access 2000

2. doing updating from grid to sql server with stored procedure sql 2000

3. VB.NET,SQL SERVER 2000 STORED PROCEDURE PARAMETERS, CRYSTAL REPORTS

4. Crystal Reports 8.5, SQL Server 2000, and Stored Procedures

5. Type Name is Invalid error -- Windows 2000/98 application with SQL Server/stored procedure problem

6. SQL Server 2000 stored procedure not returning rows

7. Logging SQL Server 2000 Stored Procedure Output

8. Help Retrieve Result From Store Procedure (SQL Server 2000)

9. SQL Server 2000 stored procedure not returning rows

10. data environment - stored procedure - ms access 2000 db

11. Access 2000 VBA - SQL stored procedure question

12. MS SQL Server BLOBS, RDO and Stored Procedures

 

 
Powered by phpBB® Forum Software