E
EricG
I'm using code like the following to run a stored procedure from Excel. Is
there a similar method to run a stored procedure that requires a parameter?
I can always hard code the SQL, but I would rather just be able to call the
procedure and provide the parameter it needs.
Thanks,
Eric
Sub RunAccessQueries_ADO()
Dim cn As ADODB.Connection
Dim cm As ADODB.Command
dbPath = "d:\data\mypath\"
dbName = "mydb.mdb"
Set cn = New ADODB.Connection
Set cm = New ADODB.Command
With cn
.CommandTimeout = 0
.Provider = "Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = "Data Source=" & dbPath & dbName
.Open
End With
With cm
.CommandText = "qryMakeTable" ' Something like "qryMakeTable " &
myParam?
.CommandType = adCmdStoredProc
.ActiveConnection = cn
.Execute
End With
'
cn.Close
'
End Sub
there a similar method to run a stored procedure that requires a parameter?
I can always hard code the SQL, but I would rather just be able to call the
procedure and provide the parameter it needs.
Thanks,
Eric
Sub RunAccessQueries_ADO()
Dim cn As ADODB.Connection
Dim cm As ADODB.Command
dbPath = "d:\data\mypath\"
dbName = "mydb.mdb"
Set cn = New ADODB.Connection
Set cm = New ADODB.Command
With cn
.CommandTimeout = 0
.Provider = "Microsoft.Jet.OLEDB.4.0;"
.ConnectionString = "Data Source=" & dbPath & dbName
.Open
End With
With cm
.CommandText = "qryMakeTable" ' Something like "qryMakeTable " &
myParam?
.CommandType = adCmdStoredProc
.ActiveConnection = cn
.Execute
End With
'
cn.Close
'
End Sub