1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
sub remplireusers()
DataSet.Clear()
DataTable2.Clear()
adapter.Fill(DataSet, "dbo.compte")
DataTable2 = DataSet.Tables("dbo.compte")
end
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
remplireusers()
If (Me.TextBox1.Text = "") Or (Me.TextBox2.Text = "") Or (Me.TextBox3.Text = "") Or (Me.TextBox4.Text = "") Or (Me.ComboBox1.SelectedItem = "") Then
Label6.Visible = True
Else
Try
DataRow = DataSet.Tables("dbo.compte").NewRow()
DataRow("nomUser") = Me.TextBox1.Text
DataRow("prenomUser") = Me.TextBox2.Text
DataRow("loginUser") = Me.TextBox3.Text
DataRow("mdpUser") = Me.TextBox4.Text
DataRow("type") = Me.ComboBox1.Text
'Mise à jour
DataSet.Tables("dbo.compte").Rows.Add(DataRow)
cmd = New SqlCommand(strSql, connexion)
cmdBuilder = New SqlCommandBuilder(adapter)
adapter.Update(DataSet, "dbo.compte")
MsgBox("Le nouveau compte a été bien crée")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
ComboBox1.Text = ""
Catch ex As Exception
MsgBox("login existe déja")
TextBox3.Text = ""
TextBox4.Text = ""
End Try
End If
end sub |
Partager