I am having difficulty with a ADP project, specifically regarding ADO / SQL usage.
I'm currently in the process of writing a function to return a resultset from a SQL table (SQL Server 2005), the code is fairly simple (see attached example).
The problem line looks to be: "Set rs_ = .Execute"... it throws the following error: "Must Declare the Scalar Variable @id".
I have tried to use '?' marks instead, but no luck; does anyone have any ideas (short of creating a stored procedure!).
On Error GoTo ErrorHandler:
Dim command_ As New ADODB.Command
Dim rs_ As ADODB.Recordset
.ActiveConnection = CurrentProject.Connection
.NamedParameters = True
.CommandType = adCmdText
.CommandText = "SELECT t.* FROM ticket t WHERE t.id = @id"
.Parameters.Append .CreateParameter("@id", adInteger, adParamInput, , 11)
Set rs_ = .Execute
If .State = adStateOpen Then
' TODO: this bit!
Set command_ = Nothing
Set rs_ = Nothing
Debug.Print Err.Description: GoTo Tidy