Senin, 02 Juni 2014

Re: [MS_AccessPros] Run-time error 91 when executing Stored Procedure in MSAccess 2013

 

Norbert-


That makes no sense to set the result of the execute of a command back to the command.  Don't you mean to do:

Set cmd = New ADODB.Command

??


John Viescas, Author
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
SQL Queries for Mere Mortals 
(Paris, France)




On Jun 2, 2014, at 2:05 PM, drnorbert@msn.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:

I am executing an stored procedure in SQL 2012 from MSAccess 2013.


The Procedure is in command button in a form.


At Set cmd=cmd.execute  a Run-time error 91 (Object variable or With block variable not set) is generated.


Any suggestions?


Thanks

Norbert


Private Sub cmdBackup_Click()
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim cmd As ADODB.Command
Dim strConnect As String

strConnect = "Provider=SQLNCLI11;Server=ISMSERVER2;Database=ISMUTIL;Trusted_Connection=Yes;"
Set cnn = New ADODB.Connection

cnn.Open strConnect

Set cmd = cmd.Execute
cmd.ActiveConnection = cnn
cmd.CommandText = "dbo.get_isdmdata_database_backups"
cmd.CommandType = adCmdStoredProc

Set rst = cmd.Execute

Set rst = Nothing
Set cnn = Nothing
Set cmd = Nothing

End Sub


__._,_.___

Posted by: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

.

__,_._,___

Tidak ada komentar:

Posting Komentar