• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

datenbank INSERT fehler

daschifahrer

Neues Mitglied
Hallo Leute,
ich hab ein Problem und zwar kann ich auf meine datenbank zu grefen etc jedoch gibt es das problem das er mir immer sagt das ich einen syntax error in meinem insert hab könnt ihr euch den insert mal anschaun?^^
Code:
"INSERT INTO  member (id, Name, Vorname, e-mail, telefon, handy, Geburtstag ) values (''," + txtname.Text + "', '" + txtvorname.Text + "', '" + txtemail.Text + "', '" + txttelefon.Text + "', '" + txthany.Text + "', '" + txtgeb.Text + "')"

mfg daschifahrer
 
Werbung:
Also, auf den ersten Blick fällt mir auf, dass das singlequote vor txtname.Text fehlt. Eventuell noch ein Tippfehler bei txthany.Text.

Gruß thuemmy
 
hab das singlequpte dazugefügt geht aber trotzdem nicht txthany ist kein tippfehler sondern gehört so ^^
ich poste mal den ganzen code vll passt da was net ...
Code:
Public Class mitglied_hinzu

    Private Sub txt_hinzu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_hinzu.Click
        Dim con As New OleDb.OleDbConnection
        Dim cmd As New OleDb.OleDbCommand
        Dim anzahl As New Double

        con.ConnectionString = _
           "Provider=Microsoft.Jet.OLEDB.4.0;" & _
           "Data Source=C:\Users\daschifahrer\Desktop\admin.mdb"
        cmd.Connection = con

        Try
            con.Open()
            cmd.CommandText = _
              "INSERT INTO  member (id, Name, Vorname, e-mail, telefon, handy, Geburtstag ) values ('', '" + txtname.Text + "', '" + txtvorname.Text + "', '" + txtemail.Text + "', '" + txttelefon.Text + "', '" + txthany.Text + "', '" + txtgeb.Text + "')"


            'MsgBox(cmd.CommandText)
            anzahl = cmd.ExecuteNonQuery()
            If anzahl > 0 Then
                MsgBox("Es wurde ein Datensatz eingefügt")
            End If
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

        con.Close()

    End Sub
End Class
 
Werbung:
Was mir auch noch aufgefallen ist, ist folgendes. Das Feld id ist sicherlich numerisch. Warum schreibst Du dann den Platzhalter mit singlequotes? Das Komma sollte reichen. Diese Annahme ist allgemeiner Natur. Ob da MS ein anderes Süppchen kocht, das weiß ich nicht.

Gruß thuemmy
 
hmm es is typ automatisch eintragen oder so aber auch das bringt nichts hat den sonst keiner eine ahnung wie das geht? -.-
 
Ja, da ist auch einiges falsch (rote Markierung fehlte bei dir) ..

Code:
"INSERT INTO  member (id, Name, Vorname, e-mail, telefon, handy, Geburtstag ) values ('',[COLOR="Red"]'[/COLOR]" + txtname.Text +"', '" + txtvorname.Text + "', '" + txtemail.Text + "', '" + txttelefon.Text + "', '" + txthany.Text + "', '" + txtgeb.Text + "')"[COLOR="Red"];[/COLOR]
 
Werbung:
Damit kenn ich mich nicht aus, aber mitten drinne fehlte auch ein einzelnes Hochkommata :mrgreen:
 
Das hatte ich ja schon angemerkt (mein 1. Postin) und er hat es in seinem 2. Codeposting auch schon geändert ;-)

Gruß thuemmy
 
Werbung:
Zurück
Oben