I getting better with this ASP.NET thing. It's great.
Now I'm having troubles with SQL string commands. I'm retrieving data no problem. Except for pulling dates.
Here my code:
Here my error message:Code:Sub Daily_Hist_Sales(sender as Object, e as EventArgs) 'http://www.w3schools.com/aspnet/aspnet_dbconnection.asp 'Database Name = great_bay_db4.mdb 'Table Name = customer Dim dbconn Dim sql,dbcomm,dbread Dim dteDate As Date 'Create a Database Connection dbconn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("great_bay_db4.mdb")) dbconn.Open() 'Create a Database Command dteDate = "08/13/2004" sql="SELECT * FROM DAILY_SALES_HIST_X WHERE DlvryDte='#8/13/2004#'" 'DOESN'T WORK 'sql="SELECT * FROM DAILY_SALES_HIST_X WHERE CustomerId='010110'" 'IT WORKS! 'sql="SELECT * FROM DAILY_SALES_HIST_X WHERE DlvryDte='dteDate'" 'DOESN'T WORK dbcomm=New OleDbCommand(sql,dbconn) 'Create a DataReader dbread=dbcomm.ExecuteReader() 'Bind to a Repeater Control Daily_Hist_Sales_Info.DataSource=dbread Daily_Hist_Sales_Info.DataBind() 'Close the Database Connection dbread.Close() dbconn.Close() End Sub
What Am I doing wrong? I tried everything. With the '#' sign, then without. I even put "8/13/2004 12:00:00 AM" what's the field.Code:Data type mismatch in criteria expression. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: Data type mismatch in criteria expression. Source Error: Line 68: dbcomm=New OleDbCommand(sql,dbconn) Line 69: 'Create a DataReader Line 70: dbread=dbcomm.ExecuteReader() Line 71: 'Bind to a Repeater Control Line 72: Daily_Hist_Sales_Info.DataSource=dbread
I just want to pull any 8/13/2004 records.
Help please
Thanks




Reply With Quote