Hello, I'm trying to import xlsx to datagrid using oledb.
but i'm geting this: Syntax error (missing operator) in query expression.I've read other related posts but didn't helped
this is the code:
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\alm1.xlsx" + @";Extended Properties=""Excel 12.0 Xml;HDR=YES;ImportMixedTypes=Text;TypeGuessRows=0""";
OleDbCommand command = new OleDbCommand("SELECT TXT" + "FROM [2$]", conn);
DataSet dstxt = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
adapter.Fill(dstxt);
dataGridView1.DataSource = dstxt.Tables[0];
can anyone help? I'm pretty sure it's a stupid mistake of me but can't figure it out.
thank you in advance.