Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-Time Error'-2147221080(800401a8)': Automation Error | Excel Programming | |||
compile error automation error | Excel Programming | |||
RunTime Error (Automation Error) | Excel Programming | |||
Automation Error, Unknown Error. Error value - 440 | Excel Programming | |||
Unknown where is the problem on the Runtime error - Automation error | Excel Programming |