PLS HELp URGENT !
I am adapting the calendar on chapter 10 of the book . i am using oledb nand i am getting an error;
Exception Details: System.Data.OleDb.OleDbException: Must declare the variable '@Date'.
Source Error:
Line 52:
Line 53: dbConnection.Open()
Line 54: Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Line 55: Return dataReader
Below is the function that should actually pass the parameter @Date
==========
Function EventsByDate(ByVal [_date] As Date) As System.Data.IDataReader
Dim connectionString As String = "Provider=SQLOLEDB;workstation id=SPC3;packet size=4096;user id=sa;data source=localhost;persist sec" & _
"urity info=True;initial catalog=hav_extranet;password=christ"
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
Dim queryString As String = "SELECT id, _date, starttime, endtime, title, audience, type, contact FROM hav_events WHERE (_date = @Date)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_date As System.Data.IDbDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_date.ParameterName = "@Date"
dbParam_date.Value = [_date]
dbParam_date.DbType = System.Data.DbType.DateTime
dbCommand.Parameters.Add(dbParam_date)
dbConnection.Open()
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)
Return dataReader
End Function
===============
_date is the date column in the database
Thanks a million!
|