Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use Excel VBA program to execute SQL SERVER stored procedur
Dear all,
I want to use Excel VBA program to execute SQL SERVER stored procedure. But error occurs."Error sql statement ,except Insert update delete procedure" How can I correct this ? thanks code: sqlstr = "exec stored_proc_name('Parameter')" Sqldb.Execute sqlstr |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use Excel VBA program to execute SQL SERVER stored procedur
Hi, in my opinion, you have to initialise the Sqldb with valid
authentication, connection string/DSN etc.... and then try running the statement. "Arron" wrote: Dear all, I want to use Excel VBA program to execute SQL SERVER stored procedure. But error occurs."Error sql statement ,except Insert update delete procedure" How can I correct this ? thanks code: sqlstr = "exec stored_proc_name('Parameter')" Sqldb.Execute sqlstr |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How to use Excel VBA program to execute SQL SERVER stored procedur
I have some sample code that executes sp_dboption to set quoted identifiers
on for Pubs, then displays all set options for Pubs database. Hope it helps some. Sub testSP() Dim cn As New ADODB.Connection Dim cmd As New ADODB.Command Dim rs As New ADODB.Recordset cn.Provider = "sqloledb" cn.Properties("Data Source").Value = "ServerName" cn.Properties("Initial Catalog").Value = "northwind" cn.Properties("Integrated Security").Value = "SSPI" cn.Open cmd.ActiveConnection = cn cmd.CommandText = _ "sp_dboption ('pubs','quoted identifier','on')" cmd.CommandType = adCmdStoredProc Set rs = cmd.Execute cmd.CommandText = "sp_dboption ('pubs')" Set rs = cmd.Execute rs.MoveFirst Do While Not rs.EOF For Each f In rs.Fields Debug.Print f.Name & vbTab & f.Value Next rs.MoveNext Loop rs.Close cn.Close End Sub -- urkec "Arron" wrote: Dear all, I want to use Excel VBA program to execute SQL SERVER stored procedure. But error occurs."Error sql statement ,except Insert update delete procedure" How can I correct this ? thanks code: sqlstr = "exec stored_proc_name('Parameter')" Sqldb.Execute sqlstr |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
execute stored proc in Excel | Excel Programming | |||
Run SQL Server stored procedure in Excel macro | Excel Programming | |||
execute stored procedure from excel | Excel Worksheet Functions | |||
Excel files stored on a different server | Excel Discussion (Misc queries) | |||
Execute a query against an excel doc and a sql server db | Excel Programming |