LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default Run a SQL Stored Procedure from VBA

I want to run a sql stored procedure from VBA but getting error.
Error is run-time error '-2147467259 (80004005)' and 2nd line 2013-06-20.
I have tried all variations found on google but getting same error.
Here is my code.
===============
Sub Run_SP()
Dim cmd As ADODB.Command
Set con = New ADODB.Connection
con.Open "Provider=SQLOLEDB;Password=anish;User ID=anish;Initial Catalog=cpcom;Data Source=bhw1;Extended Properties=Trusted_Connection=no;"
Set cmd = New ADODB.Command
With cmd
..ActiveConnection = con
..CommandText = "exec cpsrmail"
..CommandType = adCmdText
..Execute
End With
con.Close
Set cmd = Nothing
Set con = Nothing
End Sub
================
Regards,

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run a Stored Procedure from Excel Jez Excel Programming 12 October 31st 08 04:32 PM
Accessing a Stored Procedure Chad[_3_] Excel Programming 6 September 15th 08 02:39 PM
Executing Stored Procedure Jenise Excel Programming 1 October 6th 06 03:10 AM
execute stored procedure Mark Goldin Excel Programming 3 April 7th 04 03:03 PM
Execute stored procedure using DAO sapta wijaya Excel Programming 0 September 29th 03 04:24 AM


All times are GMT +1. The time now is 09:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"