Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VBA Automation error

Hi,

I am trying to execute stored procedure in SQL Server 2005 from Excel
Macro. But I am getting Automation error.

Could any one please help me to sort this problem?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VBA Automation error

Code might help.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"chezhiyan" wrote in message
oups.com...
Hi,

I am trying to execute stored procedure in SQL Server 2005 from Excel
Macro. But I am getting Automation error.

Could any one please help me to sort this problem?

Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VBA Automation error

Private Sub cmdGetReport_Click()
Dim strConn As String
Dim actcol, actrow, iCols As Integer

strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=vdb;Data Source=test"
Set conn = New ADODB.Connection
conn.Open strConn


Set cmdBudget = New ADODB.Command
cmdBudget.ActiveConnection = conn
cmdBudget.CommandText = "hesri_test"

cmdBudget.CommandType = adCmdStoredProc


Set rstBudget = cmdBudget.Execute()


' Get the active colum and row position (This will be parameter
value 1)
actcol = ActiveCell.Column
actrow = ActiveCell.Row



'Return results on to the current worksheet at the row below the
' active cell location and include a header colum in bold text
For iCols = 0 To rstBudget.Fields.Count - 1
ActiveSheet.Cells(actrow + 1, actcol + iCols).Value =
rstBudget.Fields(iCols).Name
Next iCols
ActiveSheet.Range(ActiveSheet.Cells(actrow + 1, actcol),
ActiveSheet.Cells(actrow + 1, actcol + rstBudget.Fields.Count -
1)).Font.Bold = True
ActiveSheet.Cells(actrow + 2, actcol).CopyFromRecordset
rstBudget 'datastarts at row+2

MsgBox ("data loaded")


End Sub


note: this sp takes atleast 20 mins to execute

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VBA Automation error

Private Sub cmdTEst_Click()
Dim strConn As String
Dim actcol, actrow, iCols As Integer

strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=testdb;Data Source=test"
Set conn = New ADODB.Connection
conn.Open strConn


Set cmdtest = New ADODB.Command
cmdtest.ActiveConnection = conn
cmdtest.CommandText = "hesri_test"

cmdtest.CommandType = adCmdStoredProc


Set rsttest= cmdTest.Execute()


' Get the active colum and row position (This will be parameter
value 1)
actcol = ActiveCell.Column
actrow = ActiveCell.Row



'Return results on to the current worksheet at the row below the
' active cell location and include a header colum in bold text
For iCols = 0 To rstBudget.Fields.Count - 1
ActiveSheet.Cells(actrow + 1, actcol + iCols).Value =
rsttest.Fields(iCols).Name
Next iCols
ActiveSheet.Range(ActiveSheet.Cells(actrow + 1, actcol),
ActiveSheet.Cells(actrow + 1, actcol + rsttest.Fields.Count -
1)).Font.Bold = True
ActiveSheet.Cells(actrow + 2, actcol).CopyFromRecordset rsttest
'datastarts at row+2

MsgBox ("data loaded")


End Sub

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default VBA Automation error

Try setting the connection/command timeouts before executing the command.

--
Tim Williams
Palo Alto, CA


"chezhiyan" wrote in message oups.com...
Private Sub cmdTEst_Click()
Dim strConn As String
Dim actcol, actrow, iCols As Integer

strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=testdb;Data Source=test"
Set conn = New ADODB.Connection
conn.Open strConn


Set cmdtest = New ADODB.Command
cmdtest.ActiveConnection = conn
cmdtest.CommandText = "hesri_test"

cmdtest.CommandType = adCmdStoredProc


Set rsttest= cmdTest.Execute()


' Get the active colum and row position (This will be parameter
value 1)
actcol = ActiveCell.Column
actrow = ActiveCell.Row



'Return results on to the current worksheet at the row below the
' active cell location and include a header colum in bold text
For iCols = 0 To rstBudget.Fields.Count - 1
ActiveSheet.Cells(actrow + 1, actcol + iCols).Value =
rsttest.Fields(iCols).Name
Next iCols
ActiveSheet.Range(ActiveSheet.Cells(actrow + 1, actcol),
ActiveSheet.Cells(actrow + 1, actcol + rsttest.Fields.Count -
1)).Font.Bold = True
ActiveSheet.Cells(actrow + 2, actcol).CopyFromRecordset rsttest
'datastarts at row+2

MsgBox ("data loaded")


End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default VBA Automation error

i tried setting timeout for connectiona and command object but still
it is not working

i tried with some other sp which doesn't have temp table it works fine

but when i try executing the sp which has some temp table it gives me
automation error

anbu.

Reply
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-Time Error'-2147221080(800401a8)': Automation Error BEEJAY Excel Programming 1 July 18th 06 03:13 PM
compile error automation error [email protected] Excel Programming 0 January 17th 06 08:06 AM
RunTime Error (Automation Error) KD[_3_] Excel Programming 3 January 25th 05 01:56 PM
Automation Error, Unknown Error. Error value - 440 Neo[_2_] Excel Programming 0 May 29th 04 05:26 AM
Unknown where is the problem on the Runtime error - Automation error wellie Excel Programming 1 July 10th 03 08:12 AM


All times are GMT +1. The time now is 06:27 PM.

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

About Us

"It's about Microsoft Excel"