Autor Beitrag
paddy14
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 05.05.11 15:27 
Ich habe ein Problem,
ich bekomme immer diese Fehlermeldung.

Ich habe mit Access eine DB und eine Tabelle erstellt.
Bloß ich weiß nicht was ich falsch mache, hier der Code:

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
OleDbConnection con = new OleDbConnection();
            OleDbCommand cmd = new OleDbCommand();            
            int anzahl;
            con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=C:\\Dokumente und Einstellungen\\tom\\Desktop\\Userdb.mdb";

            cmd.Connection = con;
            cmd.CommandText = "insert into User(id, name) values(11, 'tom')";

            con.Open();
            anzahl = cmd.ExecuteNonQuery();
            MessageBox.Show(anzahl+"");
            con.Close();
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19313
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 05.05.11 15:37 
Wie dir der Highlighter hier zeigt ist User ein reserviertes Wort bei SQL:
ausblenden SQL-Anweisung
1:
insert into User(id, name) values(11'tom')					

Benenne also deine Tabelle einfach besser oder hänge die Dateiendung an, das könnte auch gehen.
paddy14 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 122



BeitragVerfasst: Do 05.05.11 15:53 
Danke dir, es geht, wie blöd von mir.