M
Mark
There are two code sections below. The first does not work. The second
works. This ADP connects to a database (DB1). There is a stored procedure
that the current user has rights to in the Master Database. We wanted to
execute it using the current project connection, rather than creating a
separate connection to execute it. Why does the second work, but the first
does not? The exact error message is:
"procedure 'sp_my_stored_proc' expects parameter '@SomeInputParam', which
was not supplied"
'***************** METHOD 1 - FAILS ***************
'Create the command object using the current connection.
Dim CmdFill As adodb.Command
Set CmdFill = New adodb.Command
Set CmdFill.ActiveConnection = CurrentProject.Connection
CmdFill.CommandType = adCmdStoredProc
CmdFill.CommandText = "sp_my_stored_proc"
CmdFill.Parameters.Item("@SomeInputParam").Value = strSomeString
CmdFill.Execute
'***************** METHOD 2 - SUCCEEDS ***************
Dim cnn As adodb.Connection
Set cnn = CurrentProject.Connection
cnn.sp_my_stored_proc strSomeString
'***************** END CODE SAMPLE ******************
works. This ADP connects to a database (DB1). There is a stored procedure
that the current user has rights to in the Master Database. We wanted to
execute it using the current project connection, rather than creating a
separate connection to execute it. Why does the second work, but the first
does not? The exact error message is:
"procedure 'sp_my_stored_proc' expects parameter '@SomeInputParam', which
was not supplied"
'***************** METHOD 1 - FAILS ***************
'Create the command object using the current connection.
Dim CmdFill As adodb.Command
Set CmdFill = New adodb.Command
Set CmdFill.ActiveConnection = CurrentProject.Connection
CmdFill.CommandType = adCmdStoredProc
CmdFill.CommandText = "sp_my_stored_proc"
CmdFill.Parameters.Item("@SomeInputParam").Value = strSomeString
CmdFill.Execute
'***************** METHOD 2 - SUCCEEDS ***************
Dim cnn As adodb.Connection
Set cnn = CurrentProject.Connection
cnn.sp_my_stored_proc strSomeString
'***************** END CODE SAMPLE ******************