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
|
Try
Cn.Open() 'Ouvrir la connexion à la base
'--------------------- Enregistrement dans ta Table1 ---------------------------------
Cmd.Connection = Cn
Cmd.CommandType = CommandType.Text
Cmd.CommandText = "Insert Into Table1(Formats, Couleurs, Dimension, Quantites) Values ('" & Val(ComboBoxFormats.TXTCIN.Text) & "','" & ComboBoxCouleurs.Text & "'," & TextDimensions.Text & ",'" & ComboBoxQuantites.Text & ")"
Cmd.ExecuteNonQuery()
Cn.Close()
'--------------------- Re-Afficher DataGrid après Ajout dan la lable Table1------------------------
Cn.Open()
Ds.Clear()
ReqSQL = "Select Table1.Formats, Table1.Couleurs, Table1.Dimensions, Table1.Quantites From Table1 "
Dim Da As New OleDb.OleDbDataAdapter(ReqSQL, Cn)
Da.Fill(Ds, "Table1")
DG1.Columns(0).HeaderText = "Formats"
DG1.Columns(1).HeaderText = "Couleurs"
DG1.Columns(2).HeaderText = "Dimensions"
DG1.Columns(2).HeaderText = "Quantités"
Cn.Close()
DG1.Refresh()
'---------------------------------------------------------------------------
Catch ex As Exception
Cn.Close()
MsgBox(ex.Message)
End Try |
Partager