excelhelp20817
New Member
- Joined
- Aug 6, 2013
- Messages
- 6
Hi. I am trying to run a stored SQL procedure in VBA. I have the below code. I get "Syntax error or access violation" on the objMyCmd.Execute line. I feel like I am not correctly pointing to the location of the stored procedure. Anyone have any ideas? The query I am trying to run is named "sql query test"
Any help is greatly appreciated. Thanks.
sub test
'Gets Raw Data From SQL
'Declare variables'
Set objMyConn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set objMyRecordset = New ADODB.Recordset
Dim myConStr As String
myConStr = --connection data is here. Don't want to post.
'Open Connection'
objMyConn.ConnectionString = myConStr
objMyConn.Open
'Set and Excecute SQL Command'
Set objMyCmd.ActiveConnection = objMyConn
objMyCmd.CommandText = "sql query test"
objMyCmd.CommandType = adCmdStoredProc
objMyCmd.Execute
end sub
Any help is greatly appreciated. Thanks.
sub test
'Gets Raw Data From SQL
'Declare variables'
Set objMyConn = New ADODB.Connection
Set objMyCmd = New ADODB.Command
Set objMyRecordset = New ADODB.Recordset
Dim myConStr As String
myConStr = --connection data is here. Don't want to post.
'Open Connection'
objMyConn.ConnectionString = myConStr
objMyConn.Open
'Set and Excecute SQL Command'
Set objMyCmd.ActiveConnection = objMyConn
objMyCmd.CommandText = "sql query test"
objMyCmd.CommandType = adCmdStoredProc
objMyCmd.Execute
end sub