|
| Autor |
Nachricht |
weltenspalter Newbie

Anmeldedatum: 13.07.2009 Beiträge: 1
|
Datentypen und Kriterienausdruck unverträglich
Verfasst am: 13.07.2009, 08:55 |
|
|
Hallo Leute,
ich weiß mir nicht mehr zu helfen. Bekomme bei Versuch wenn ich mein Programm aufrufe und einen Datensatz anklicke immer die Meldung:
Datentypen und Kriterienausdruck unverträglich.
Kann mir da jemand helfen?!
| Code: |
Imports System.IO
Public Class frm0802
Dim con As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim reader As OleDb.OleDbDataReader
Dim pnummer As New ArrayList
Private Sub frm0802_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Temp\firma.mdb"
cmd.Connection = con
End Sub
Private Sub cmdSehen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSehen.Click
AlleSehen()
End Sub
Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
If txtNachname.Text = "" Then
MsgBox("Bitte einen Such-Namen eintragen(Nachname)")
Exit Sub
End If
Try
con.Open()
cmd.CommandText = "select * from berater where nachname like '%" & txtNachname.Text & "%'"
'MsgBox(cmd.CommandText)
Ausgabe()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End Sub
Private Sub cmdEinfügen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEinfügen.Click
Dim anzahl As Integer
If txtGulpid.Text = "" Then
MsgBox("Bitte mindestens eine Gulp ID eintragen")
Exit Sub
End If
Try
con.Open()
cmd.CommandText = _
"insert into berater " & _
"(firma, strasse, plz, ort, land, hauptagentur, " & _
"gulpid, geburtsjahr, stundensatz, anrede,satznummer, vorname, nachname, " & _
"titel, telefon, telefax, mobiltelefon, email, verfuegbarkeit)" & _
"values ('" & _
txtFirma.Text & "', '" & _
txtStrasse.Text & "', '" & _
txtPlz.Text & "', '" & _
txtOrt.Text & "', '" & _
txtLand.Text & "', '" & _
txtHauptagentur.Text & "', '" & _
txtGulpid.Text & "', '" & _
txtGeburtsjahr.Text & "', '" & _
txtStundensatz.Text & "', '" & _
txtAnrede.Text & "', '" & _
txtSatznummer.Text & "', '" & _
txtVorname.Text & "', '" & _
txtNachname.Text & "', '" & _
txtTitel.Text & "', '" & _
txtTelefon.Text & "', '" & _
txtTelefax.Text & "', '" & _
txtMobiltelefon.Text & "', " & _
txtEmail.Text & ", '" & _
txtVerfuegbarkeit.Text & "')"
'MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery() 'Fehler
If anzahl > 0 Then
MsgBox("Es wurde ein Datensatz eingefügt")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
AlleSehen()
End Sub
Private Sub cmdÄndern_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdÄndern.Click
Dim anzahl As Integer
If txtGulpid.Text = "" Then
MsgBox("Bitte einen Datensatz auswählen " & "und mindestens eine Gulp ID eintragen")
Exit Sub
End If
Try
con.Open()
cmd.CommandText = "update berater set " & _
"firma = '" & txtFirma.Text & "', " & _
"strasse = '" & txtStrasse.Text & "', " & _
"plz = '" & txtPlz.Text & "', " & _
"ort = '" & txtOrt.Text & "', " & _
"land = '" & txtLand.Text & "', " & _
"hauptagentur = '" & txtHauptagentur.Text & "', " & _
"gulpid = " & txtGulpid.Text & ", " & _
"geburtsjahr = '" & txtGeburtsjahr.Text & "', " & _
"stundensatz = '" & txtStundensatz.Text & "', " & _
"anrede = '" & txtAnrede.Text & "', " & _
"satznummer = '" & txtSatznummer.Text & "', " & _
"vorname = '" & txtVorname.Text & "', " & _
"nachname = '" & txtNachname.Text & "', " & _
"titel = '" & txtTitel.Text & "', " & _
"telefon = '" & txtTelefon.Text & "', " & _
"telefax = '" & txtTelefax.Text & "', " & _
"mobiltelefon = '" & txtMobiltelefon.Text & "', " & _
"anrede = '" & txtAnrede.Text & "', " & _
"email = " & txtEmail.Text & ", " & _
"verfuegbarkeit = '" & txtVerfuegbarkeit.Text & "' " & _
"where satznummer = " & _
pnummer(lstTab.SelectedIndex)
'MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery()
If anzahl > 0 Then
MsgBox("Es wurde ein Datensatz geändert")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
AlleSehen()
End Sub
Private Sub cmdLöschen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLöschen.Click
Dim anzahl As Integer
If txtGulpid.Text = "" Then
MsgBox("Bitte einen Datensatz auswählen")
Exit Sub
End If
If MsgBox("Wollen Sie den ausgewählten " & "Datensatz wirklich löschen?", MsgBoxStyle.YesNo) = MsgBoxResult.No Then
Exit Sub
End If
Try
con.Open()
cmd.CommandText = "delete from berater " & _
"where satznummer = " & pnummer(lstTab.SelectedIndex)
'MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery()
If anzahl > 0 Then
MsgBox("Es wurde ein Datensatz gelöscht")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
AlleSehen()
End Sub
Sub AlleSehen()
Try
con.Open()
cmd.CommandText = "select * from berater"
Ausgabe()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
txtFirma.Text = ""
txtStrasse.Text = ""
txtPlz.Text = ""
txtOrt.Text = ""
txtLand.Text = ""
txtHauptagentur.Text = ""
txtGulpid.Text = ""
txtGeburtsjahr.Text = ""
txtStundensatz.Text = ""
txtAnrede.Text = ""
txtSatznummer.Text = ""
txtVorname.Text = ""
txtNachname.Text = ""
txtTitel.Text = ""
txtTelefon.Text = ""
txtTelefax.Text = ""
txtMobiltelefon.Text = ""
txtEmail.Text = ""
txtVerfuegbarkeit.Text = ""
End Sub
Sub Ausgabe()
reader = cmd.ExecuteReader()
lstTab.Items.Clear()
pnummer.Clear()
Do While reader.Read()
lstTab.Items.Add(reader("firma") & " # " _
& reader("strasse") & " # " _
& reader("plz") & " # " _
& reader("ort") & " # " _
& reader("land") & " # " _
& reader("hauptagentur") & " # " _
& reader("gulpid") & " # " _
& reader("geburtsjahr") & " # " _
& reader("stundensatz") & " # " _
& reader("anrede") & " # " _
& reader("satznummer") & " # " _
& reader("vorname") & " # " _
& reader("nachname") & " # " _
& reader("titel") & " # " _
& reader("telefon") & " # " _
& reader("telefax") & " # " _
& reader("mobiltelefon") & " # " _
& reader("email"))
pnummer.Add(reader("satznummer"))
Loop
reader.Close()
End Sub
Private Sub lstTab_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstTab.SelectedIndexChanged
Try
con.Open()
cmd.CommandText = "select * from berater where satznummer = " & pnummer(lstTab.SelectedIndex)
reader = cmd.ExecuteReader()
reader.Read()
txtFirma.Text = reader("firma")
txtStrasse.Text = reader("strasse")
txtPlz.Text = reader("plz")
txtOrt.Text = reader("ort")
txtLand.Text = reader("land")
txtHauptagentur.Text = reader("hauptagentur")
txtGulpid.Text = reader("gulpid")
txtGeburtsjahr.Text = reader("geburtsjahr")
txtStundensatz.Text = reader("stundensatz")
txtAnrede.Text = reader("anrede")
txtSatznummer.Text = reader("satznummer")
txtVorname.Text = reader("vorname")
txtNachname.Text = reader("nachname")
txtTitel.Text = reader("titel")
txtTelefon.Text = reader("telefon")
txtTelefax.Text = reader("telefax")
txtMobiltelefon.Text = reader("mobiltelefon")
txtEmail.Text = reader("email")
txtVerfuegbarkeit.Text = reader("verfuegbarkeit")
reader.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
con.Close()
End Sub
Private Sub cmdInternet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInternet.Click
Call URL_Load("http://www.google.de" & txtNachname.Text)
End Sub
Private Sub URL_Load(ByVal sURL As String)
Dim appIE As Object
Dim sTxt As String
appIE = CreateObject("InternetExplorer.Application")
appIE.navigate(sURL)
Do : Loop Until appIE.Busy = False
Do : Loop Until appIE.Busy = False
sTxt = appIE.document.documentElement.outerHTML
appIE = Nothing
'StreamWriter-Instanz bilden und Datei öffnen, =False: Existierende Datei überschreiben, sonst erstellen
Dim Ausgabe As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("C:\test\test.txt", False)
Ausgabe.WriteLine(sTxt) 'Variable sTxt in Testdatei schreiben
Ausgabe.Close() ' Textdatei schließen
Dim TempString() As String
Dim Zaehler As Integer = 0
TempString = System.IO.File.ReadAllLines("c:\test\test.txt")
While Zaehler <= TempString.Length - 1
If TempString(Zaehler).StartsWith("Verfügbar ab") Then
txtInternet.Text = (TempString(Zaehler))
End If
Zaehler += 1
End While
End Sub
Private Sub cmdUpdateInternet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdateInternet.Click
Dim anzahl As Integer
If txtGulpid.Text = "" Then
MsgBox("Bitte einen Datensatz auswählen " & "und mindestens eine Gulp ID eintragen")
Exit Sub
End If
Try
con.Open()
cmd.CommandText = "update berater set " & _
"firma = '" & txtFirma.Text & "', " & _
"strasse = '" & txtStrasse.Text & "', " & _
"plz = '" & txtPlz.Text & "', " & _
"ort = '" & txtOrt.Text & "', " & _
"land = '" & txtLand.Text & "', " & _
"hauptagentur = '" & txtHauptagentur.Text & "', " & _
"gulpid = " & txtGulpid.Text & ", " & _
"geburtsjahr = '" & txtGeburtsjahr.Text & "', " & _
"stundensatz = '" & txtStundensatz.Text & "', " & _
"anrede = '" & txtAnrede.Text & "', " & _
"satznummer = '" & txtSatznummer.Text & "', " & _
"vorname = '" & txtVorname.Text & "', " & _
"nachname = '" & txtNachname.Text & "', " & _
"titel = '" & txtTitel.Text & "', " & _
"telefon = '" & txtTelefon.Text & "', " & _
"telefax = '" & txtTelefax.Text & "', " & _
"mobiltelefon = '" & txtMobiltelefon.Text & "', " & _
"anrede = '" & txtAnrede.Text & "', " & _
"email = " & txtEmail.Text & ", " & _
"verfuegbarkeit = '" & txtVerfuegbarkeit.Text & "' " & _
"where satznummer = " & _
pnummer(lstTab.SelectedIndex)
'MsgBox(cmd.CommandText)
anzahl = cmd.ExecuteNonQuery()
If anzahl > 0 Then
MsgBox("Es wurde ein Datensatz geändert")
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
'Application.ScreenUpdating = False
txtVerfuegbarkeit.Text = txtInternet.Text
con.Close()
txtInternet.Text = ""
End Sub
End Class
|
Der Fehler kommen bei:
| Code: |
anzahl = cmd.ExecuteNonQuery()
|
und
| Code: |
reader = cmd.ExecuteReader()
|
Kann mir jemand helfen?
Danke schon einmal im Vorraus. |
|
| |
|
 |
|
|