Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles MyBase.Load cn = New OleDbConnection cn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=c:\mesbases\TP2.mdb" cn.Open()cmdselect = New OleDbCommand cmdselect.Connection = cn cmdselect.CommandText = "select nof,noc,nop,titre,datesortie,nombre,cout,dvd from films order by nof" ds = New DataSet da = New OleDbDataAdapter da.SelectCommand = cmdselect da.Fill(ds, "films") Dim col As DataColumn = ds.Tables(0).Columns(0) col.AutoIncrement = True col.AutoIncrementSeed = -1 col.AutoIncrementStep = -2 Dim pk(0) As DataColumn pk(0) = col ds.Tables(0).PrimaryKey = pk courant = 0 'binder les controles
b1 = TextBox1.DataBindings.Add("text", ds, "films.titre") ' sa propriete text b2 = TextBox2.DataBindings.Add("text", ds, "films.cout") dtp.DataBindings.Add("value", ds, "films.datesortie") 'sa propriete value
AddHandler b2.Format, AddressOf formatterMontant ' le signe $$$ cm = BindingContext(ds, "films") 'creer currency manager
Label11.Text = (cm.Position + 1).ToString() + " de " + cm.Count().ToString()
' cm.Position += 1 'pour ajouter le $$$$$$
' cm.Position -= 1 'pour ajouter le $$$$$$
afficher()
End Sub
Private Sub afficher()
Dim enrg As DataRow = ds.Tables(0).Rows(courant)
If enrg.RowState <> DataRowState.Deleted Then
Label6.Text = enrg("nof")
TextBox1.Text = enrg("titre")
TextBox2.Text = enrg("cout")
Else
Label6.Text = enrg("nof", DataRowVersion.Original)
TextBox1.Text = enrg("titre", DataRowVersion.Original)
TextBox2.Text = enrg("cout", DataRowVersion.Original)
End If
Label11.Text = (courant + 1).ToString() + " de " + ds.Tables(0).Rows.Count.ToString()
End Sub