I am trying to get some data out of a FoxPro9-Database using the OleDB-Driver but it throws an error when using different types of dates. I'll show you an example:
I have the following function, which fills a DataGrid with the desired information:
public void SqlQuery(String SQL)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=VFPOLEDB;" +
"Data Source=dbfs\\drive.dbc;" +
"Collating Sequence=machine;" +
"Password=;" +
"Mode=Share Deny Write;";
conn.Open();
OleDbCommand cmd = new OleDbCommand(SQL, conn);
try
{
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable DTable = new DataTable();
da.Fill(DTable);
dataGrid.DataSource = DTable;
conn.Dispose();
conn.Close();
}
catch (OleDbException e)
{
MessageBox.Show(e.ToString());
}
}
If I use this SQL-Command it works fine:
SqlQuery("SELECT * FROM hotges.dbf WHERE hot_erlsup = 'myname' AND hot_erldat >= DATE(2012,05,02) AND hot_erldat <= DATE(2012,05,03)");
But here I have a problem, because VFP-Databases use Datetime and not Date, so the command above would select only data starting from 02 May 2012 at 00:00:00 until 03 May 2012 at 00:00:00. I would like to select until 03 May 2012 at 23:59:59. If I use DATETIME() or SMALLDATETIME() or anything else it throws an error saying this function is missing...
How can I solve this problem?

New Topic/Question
Reply



MultiQuote



|