Question : Cannot execute stored procs from Access without using SQL Native Client driver

I have an MS Access 2003 DB which uses ADO to execute a stored proc on a SQL 2005 DB.  For some reason, I need to use the "SQL Native Client" driver to (in the DSN) to be able to execute stored procs.  When using the SQL 2000 "SQL Server" driver, I cannot execute sp's.  All the other functions (such as linking to tables) all work fine.

Unfortunately, I am working in an environment where all the pc's are locked and most of the pc's don't have the SQL Native Client driver installed.  It will take too long to get the SQL Native Client installed on all the machines.

Does anyone know a way around this problem?

Answer : Cannot execute stored procs from Access without using SQL Native Client driver

I'd agree that if an import to a local table were in operation then a passthrough really would be the way to go for such a batch operation.  (I presume you're not pushing the data out from SQL Server - but that to a local source would be hard to believe).

However for other scenarios exeuting the SP on the server is very often performed through an ADO connection.
On your code front, I see you're refering to a DSN.
While you want to do that then you're using the ODBC driver to establish your connection - is there a problem with the ODBC driver version I wonder.   (I'd ordinarily say make sure you install the latest MDAC - but you're already limited in what you can do on these client machines).

Try the OLEDB provider anyway.
cnBE.ConnectionString = "Provider=SQLOLEDB;Data Source=MyServer;Integrated Security=SSPI;Initial Catalog=MyDB;"  
See how you go.

FWIW I wouldn't recommend you Refresh the Parameters collection anyway.
You can get away with that in client side development (i.e. Access against Jet) as the query definition is local.  But the Refresh of the collection is another trip to the server which you don't need (as you already know the name of your return parameter name - you need to to know the datatype too - but you should anyway of course).

Your code would then become...

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
    With myCmd
        .ActiveConnection = cnBE
        .CommandType = adCmdStoredProc
        .CommandText = "spMyProcedure"
        .Parameters.Append .CreateParameter("@Return_Value", adInteger, adParamOutput)
        .Execute
        
        If .Parameters("@Return_Value") <> 0 Then
            MsgBox "Import failed. "
        Else
            MsgBox "Import successful"
        End If
    End With
Random Solutions  
 
programming4us programming4us