-4
string Category = comboBox1.Text;
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\\Users\\admin\\Documents\\INV.xlsx; Extended Properties=\"Excel 8.0\"";
OleDbConnection connection = new OleDbConnection(connectionString);
string sql = "SELECT * FROM [RAW DATA$] WHERE [Category: Name] = @Category";
OleDbCommand cmd = new OleDbCommand(sql, connection);
cmd.Parameters.AddWithValue("@num", SqlDbType.Int).Value = Category;
OleDbDataAdapter dataadapter = new OleDbDataAdapter(sql, connection);
標準的問題與Access (jet oledb)是將它不知道的所有內容解釋爲參數,因此請確保您的執行文件有一個名爲「Category:Name」的列和一個名爲「RAW DATA $」的表。 –
而你的問題是? –