Hallo zusammen, ich habe ein form .. wenn ich button1 - übernehmen klicke speichert er mmir den datensatz nicht ab,
warum nicht ? Die überpruefung klappt... wenn ich was weg lasse meckert er artig.
hier mal den code...
thx schon mal ronaldl
warum nicht ? Die überpruefung klappt... wenn ich was weg lasse meckert er artig.
hier mal den code...
VB.NET-Quellcode
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- 'Felder und werte überpruefen
- If ComboBox2.Text = "" Or Nothing Then
- MsgBox(" Bitte erst eine Anrede auswählen !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Anrede !")
- ComboBox2.Focus()
- ElseIf ComboBox3.Text = "" Or Nothing Then
- MsgBox(" Bitte erst eine Briefanrede auswählen !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Briefanrede")
- ComboBox3.Focus()
- ElseIf ComboBox4.Text = "" Or Nothing Then
- MsgBox(" Bitte erst ein Land auswählen !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Land")
- ComboBox3.Focus()
- ElseIf TextBox3.Text = "" Or Nothing Then
- MsgBox(" Bitte erst einen Familiennamen eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Briefanrede")
- TextBox3.Focus()
- ElseIf TextBox4.Text = "" Or Nothing Then
- MsgBox(" Bitte erst einen Straßenamen eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Straßenamen")
- TextBox4.Focus()
- ElseIf ComboBox5.Text = "" Or Nothing Then
- MsgBox(" Bitte erst ein Bundesland auswählen !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Bundesland")
- ComboBox5.Focus()
- ElseIf TextBox5.Text = "" Or Nothing Then
- MsgBox(" Bitte erst eine Hausnummer eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Hausnummer")
- TextBox5.Focus()
- ElseIf TextBox6.Text = "" Or Nothing Then
- MsgBox(" Bitte erst eine Postleitzahl eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Postleitzahl")
- TextBox6.Focus()
- ElseIf TextBox7.Text = "" Or Nothing Then
- MsgBox(" Bitte erst einen Ortsnamen eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Ortsnamen")
- TextBox7.Focus()
- ElseIf TextBox8.Text = "" Or Nothing Then
- MsgBox(" Bitte erst eine Telefon Vorwahl eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Telefon Vorwahl")
- TextBox8.Focus()
- ElseIf TextBox9.Text = "" Or Nothing Then
- MsgBox(" Bitte erst eine Telefon Nummer eingben !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Telefon Nummer")
- TextBox9.Focus()
- ElseIf TextBox1.Text <> "" Then
- Dim tl1 As Integer = TextBox1.Text.Length
- If tl1 < 3 Then
- MsgBox(" Firmenname ist zu Kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Firma")
- TextBox1.Focus()
- End If
- ElseIf TextBox2.Text <> "" Then
- Dim tl2 As Integer = TextBox2.Text.Length
- If tl2 < 3 Then
- MsgBox(" Vorname ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Vorname")
- TextBox2.Focus()
- End If
- ElseIf TextBox3.Text <> "" Then
- Dim tl3 As Integer = TextBox3.Text.Length
- If tl3 < 3 Then
- MsgBox(" Zuname ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Zuname")
- TextBox3.Focus()
- End If
- ElseIf TextBox4.Text <> "" Then
- Dim tl4 As Integer = TextBox4.Text.Length
- If tl4 < 3 Then
- MsgBox(" Straßenname ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Straßennname")
- TextBox4.Focus()
- End If
- ElseIf TextBox6.Text <> "" Then
- Dim tl6 As Integer = TextBox6.Text.Length
- If tl6 < 4 Then
- MsgBox(" PLZ ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld PLZ")
- TextBox6.Focus()
- ElseIf tl6 > 5 Then
- MsgBox(" PLZ ist zu lang !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld PLZ")
- TextBox6.Focus()
- End If
- ElseIf TextBox7.Text <> "" Then
- Dim tl7 As Integer = TextBox4.Text.Length
- If tl7 < 3 Then
- MsgBox(" Ortsname ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Ortsname")
- TextBox7.Focus()
- End If
- ElseIf TextBox8.Text <> "" Then
- Dim tl8 As Integer = TextBox4.Text.Length
- If tl8 < 3 Then
- MsgBox(" Vorwahl ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Vorwahl")
- TextBox8.Focus()
- End If
- ElseIf TextBox9.Text <> "" Then
- Dim tl9 As Integer = TextBox4.Text.Length
- If tl9 < 4 Then
- MsgBox(" Telefonnr ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld Telefonnummer")
- TextBox9.Focus()
- End If
- If RadioButton3.Checked = False And RadioButton4.Checked = False And RadioButton5.Checked = False And RadioButton6.Checked = False Then
- MsgBox("Bitte Art der Telefonnummer auswählen !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Auswahl der Telefonnummern Artr")
- End If
- ElseIf TextBox10.Text <> "" Then
- Dim tl10 As Integer = TextBox10.Text.Length
- If tl10 < 10 Then
- MsgBox(" Emailadresse ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld E-Mailadresse")
- TextBox10.Focus()
- End If
- If TextBox10.Text.Contains("@") Then
- MsgBox(" Emailadresse hat kein @ Zeichen !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld E-Mailadresse")
- TextBox10.Focus()
- End If
- Dim tvax As String = TextBox10.Text
- Dim tva0() = Split(tvax, "@")
- Dim tval As String = tva0(0).Length
- Dim tnal As String = tva0(1).Length
- Dim tld0() = Split(tvax, ".")
- Dim tldlwert As Integer = tld0.Count - 1
- Dim tld As String = tld0(tldlwert).Length
- If tval < 3 Then
- MsgBox(" Emailadresse ist vorm @ zeichen zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld E-Mailadresse")
- TextBox10.Focus()
- ElseIf tnal < 3 Then
- MsgBox(" Emailadresse ist nach @ zeichen zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld E-Mailadresse")
- TextBox10.Focus()
- End If
- If tld < 2 Then
- MsgBox(" die TLD-Kennung der Emailadresse ist zu kurz !", MsgBoxStyle.Exclamation, "Achtung, Problem mit Inhalt im Eingabefeld E-Mailadresse")
- TextBox10.Focus()
- End If
- MsgBox(" überpruefen problem ")
- Else
- MsgBox(" überpruefen abgeschlossen ") ' Die hier geht schon nicht.. grrr...
- 'Kundendaten Speichern
- 'lnr holen
- Dim lnr0 As Integer = 0
- Dim sql1 As String = "select lnr from users order by lnr desc "
- Dim con1 As New MySqlConnection
- Dim cmd1 As New MySqlCommand(sql1, con1)
- Dim myAdapter1 As New MySqlDataAdapter
- con1.ConnectionString = "server='" & dbh & "';" _
- & "uid='" & dbu & "';" _
- & "pwd='" & dbp & "';" _
- & "database='" & dbd & "';"
- Try
- con1.Open() ' Verbindung öffnen
- Catch myerror As MySqlException
- MsgBox("Keine Verbindung zur Datenbank : " & myerror.Message.ToString) ' Falls Fehler : Fehler anzeigen
- End Try
- Try
- lnr0 = cmd1.ExecuteScalar
- con1.Close()
- Catch ex As Exception
- MsgBox(ex.Message & " Problem neuer anlage kdnr")
- Finally
- End Try
- 'Anrede und geschlecht auswerten
- Dim selectedIndexA As Integer
- selectedIndexA = ComboBox1.SelectedIndex
- Dim selectedItemA As Object
- selectedItemA = ComboBox1.SelectedItem.Split("/").GetValue(0)
- Dim selectedItemG As Object
- selectedItemG = ComboBox1.SelectedItem.Split("/").GetValue(1)
- Dim wertA As String
- wertA = selectedItemA
- Dim wertG1 As String
- Dim wertG As String
- wertG1 = selectedItemG
- wertG = Replace(wertG1, " ", "")
- 'briefanrede auswerten
- Dim selectedIndexB As Integer
- selectedIndexB = ComboBox2.SelectedIndex
- Dim selectedItemB As Object
- selectedItemB = ComboBox2.SelectedItem.Split("/").GetValue(0)
- Dim wertB As String
- wertB = selectedItemB
- Dim spart As String = ""
- Dim felder As String = ""
- Dim werte As String = ""
- Dim insert As String = ""
- Dim con As New MySqlConnection
- Dim myAdapter As New MySqlDataAdapter
- con.ConnectionString = "server='" & dbh & "';" _
- & "uid='" & dbu & "';" _
- & "pwd='" & dbp & "';" _
- & "database='" & dbd & "';"
- Try
- con.Open() ' Verbindung öffnen
- con.Close()
- Catch myerror As MySqlException
- MsgBox("Keine Verbindung zur Datenbank : " & myerror.Message.ToString) ' Falls Fehler : Fehler anzeigen
- End Try
- Dim ath As String = "NULL"
- Dim n0 As String = "0"
- Dim n1 As String = ""
- Dim statu = "active"
- Dim tipe As String = "sing"
- Dim hkd As String = "t"
- Dim kart As String = "Lieferung"
- Dim art As String = "ku"
- Dim telfp As String = ""
- Dim telmp As String = ""
- Dim telff As String = ""
- Dim telmf As String = ""
- Dim emailp As String = ""
- Dim emailg As String = ""
- Dim lnr1 As String = lnr0 + 1
- Dim lnr As String = lnr1.ToString
- If tart = "fp" Then
- telfp = Label23.Text
- telmp = n1
- telff = n1
- telmf = n1
- emailp = TextBox10.Text
- emailg = n1
- ElseIf tart = "mp" Then
- telfp = n1
- telmp = Label23.Text
- telff = n1
- telmf = n1
- emailp = TextBox10.Text
- emailg = n1
- ElseIf tart = "ff" Then
- telfp = n1
- telmp = n1
- telff = Label23.Text
- telmf = n1
- emailp = n1
- emailg = TextBox10.Text
- ElseIf tart = "ff" Then
- telfp = n1
- telmp = n1
- telff = n1
- telmf = Label23.Text
- emailp = n1
- emailg = TextBox10.Text
- End If
- spart = "INSERT INTO users"
- felder = "(id,uid,auth,pwd,email,fname,lname,addr,city,state,country,zipcode,phone,datesignup,status,type,Anrede,hkd,art,kdnr,hnr,gphone,mobile,gmobile,fax,gfax,gemail,vkart,lnr,banrede,firma,geb)"
- ' id, uid, auth, pwd, email, fname, lname, addr, city, state, country, zipcode, phone, datesignup, status, type, Anrede, hkd, art, kdnr, hnr, gphone, mobile, gmobile, fax, gfax, gemail, vkart, lnr, banrede, firma, geb
- werte = "('" & Label13.Text & "','" & n0 & "'," & ath & ",'" & n0 & "','" & emailp & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox7.Text & "','" & Label22.Text & "','" & Label21.Text & "','" & TextBox6.Text & "','" & telfp & "','" & Label15.Text & "','" & statu & "','" & tipe & "','" & wertG & "','" & hkd & "','" & art & "','" & Label3.Text & "','" & TextBox5.Text & "','" & telff & "','" & telmf & "','" & telmf & "','" & n1 & "','" & n1 & "','" & emailg & "','" & kart & "','" & lnr & "','" & wertB & "','" & TextBox1.Text & "','" & n1 & "')"
- Dim sqls As String = "" & spart & felder & "values" & werte & ""
- Dim cmds As New MySqlCommand(sqls, con)
- Dim anzahls As Integer '= 0
- Try
- con.Open()
- anzahls = cmds.ExecuteNonQuery()
- con.Close()
- SP0 = "ja"
- MsgBox(SP0)
- Catch myerror As MySqlException
- MsgBox("Fehler bei speichern" & myerror.Message.ToString) ' Falls Fehler : Fehler anzeigen
- End Try
- End If
- If SP0 = "ja" Then
- MsgBox(" Adresse ist gespeichert ")
- Me.Close()
- End If
- End Sub
thx schon mal ronaldl