|
Hi,
I have an excel sheet with Date as one of the field. The format of date in excel sheet is dd/mm/yyyy. I have connected C# with excel through OLEDB. My code is,
string excel_connection_string = @"Provider=Microsoft.Jet.OLEDB.4.0;DATA Source=C:\Seetha's\Projects\StockAnalysis\Lloyds.xls;Extended Properties=Excel 8.0;"; OleDbDataAdapter exceladapter = new OleDbDataAdapter("Select * from [st$]", excel_connection_string); DataSet ds = new DataSet(); exceladapter.Fill(ds, "StockInfo"); Grid1.DataSource = ds.Tables["StockInfo"].DefaultView; Grid1.DataBind();
This works perfectly. But problem comes when i try to use Date field in the 'where' clause of Sql query. If i use the query OleDbDataAdapter exceladapter = new OleDbDataAdapter("Select * from [st$] where convert(varchar(19), StockDate, 120) between '2008-01-01' and '2008-07-30'", excel_connection_string); where StockDate is the date field in the excel sheet.
It shows oledbexception as Undefined function 'convert' in expression. I want the values from excel sheet within the given range of date. Please help.
|