Hallo,
ich habe da mal eine Frage zu folgendem Code:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
| private void ExportToExcelFile(string excelFileNamePath) {
string SQLCONNECTION = "Data Source=" + excelFileNamePath + ";Provider=Microsoft.Jet.OLEDB.4.0;" + @"Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1""";
using (OleDbConnection con = new OleDbConnection(SQLCONNECTION)) { string sql = "INSERT INTO [Tabelle1$] ([condition], [comdmand], [parameter1], [parameter2]) VALUES ('Name', 'Email', 'Subject', 'Text')";
OleDbCommand cmd = new OleDbCommand(sql, con);
con.Open(); cmd.ExecuteNonQuery(); con.Close(); } } |
Immer wenn ich ihn ausführe bekomme ich eine Exception ("Operation muss eine aktualisierbare Abfrage verwenden.") Die Frage ist nun was meint er damit? Die Exceldatei existiert, sie hat auch ein Sheet namens Tabelle1 und sogar condition, command usw. als Spaltenüberschriften. Was also will er noch?
Ich frage mich allerdings auch woher er weiß in welche Zelle er die Daten schreiben soll. Sollte das etwa der Fehler sein?
Wäre nett wenn mir irgendjemand weiterhelfen könnte.
Danke!
Scofield2011