My connection string
<add connectionString="Driver={Microsoft Text Driver (*.txt; *.csv)}; Dbq=E:; Extensions=asc,csv,tab,txt;"
name="TestConnectionString"/>
My C# code:
protected void ExecuteButton_Click(object sender, EventArgs e)
{
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["TestConnectionString"].ConnectionString;
using (OdbcConnection con = new OdbcConnection(connectionString))
{
con.Open();
string sql = "SELECT date_id FROM date_conversion.csv WHERE [date_in_ad] = '4/13/1944'";
using (OdbcCommand command = new OdbcCommand(sql, con))
{
ResultTextBox.Text = Convert.ToString(command.ExecuteScalar());
}
}
}
My CSV file:
date_id date_in_ad ad_month_id ad_date_id ad_year_id
1 4/13/1944 4 13 1944
2 4/14/1944 4 14 1944
3 4/15/1944 4 15 1944
4 4/16/1944 4 16 1944
5 4/17/1944 4 17 1944
I am receiving following error: System.Data.Odbc.OdbcException: ERROR [22018] [Microsoft][ODBC Text Driver] Data type mismatch in criteria expression.