0
Follow below the line of code
private void button7_Click(object sender, EventArgs e)
{
string conex = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + textBox1.Text + ";Extended Properties=\"Excel 8.0;HDR=YES;\";";
OleDbConnection conn = new OleDbConnection(conex);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter("SELECT * FROM [" + textBox2.Text + "$] where DATA ="+ dateTimePicker1.Value , conn);
DataTable dt = new DataTable();
myDataAdapter.Fill(dt);
dataGridView1.DataSource = dt;
}
I try to return a value by searching for Data, but only find errors. No single quotes(as in the code), returns error =
System.Data.OleDb.OleDbException: 'Erro de sintaxe (operador faltando) na expressão de consulta 'DATA =18/12/2020 08:20:04'.'
When I put single quotes in the query around the error dateTimePicker =
System.Data.OleDb.OleDbException: 'Tipo de dados imcompatível na expressão de critério.'
No, DATA is the column name of all the Dates, and I want to fetch the values.
– Felipe de Souza