Connection Base de donnée avec vb.net
Cours : Connection Base de donnée avec vb.net. Recherche parmi 300 000+ dissertationsPar YassineMf • 13 Janvier 2020 • Cours • 682 Mots (3 Pages) • 479 Vues
Imports System.Data.SqlClient
Public Class Form1
'chaine de conection
Dim constring As New SqlConnection("Data Source=.\SQLEXPRESS;Initial Catalog=reservation;Integrated Security=True")
Dim index As Integer = -1
Dim table As New DataTable()
Public Sub showData(ByVal position As Integer)
'methode pour retirer les donnes
Dim command As New SqlCommand("select * from Riad", constring)
Dim adapter As New SqlDataAdapter(command)
adapter.Fill(table)
nume.Text = table.Rows(position)(0).ToString()
nome.Text = table.Rows(position)(1).ToString()
adress.Text = table.Rows(position)(2).ToString()
nombr.Text = table.Rows(position)(3).ToString()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'afficher le premier
index = 0
showData(index)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
'afficher dernier
index = table.Rows.Count() - 1
showData(index)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'afficher precedent
index -= 1
If index < 0 Then
index = 0
End If
showData(index)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'afficher suivant
index += 1
If index > table.Rows.Count() - 1 Then
index = table.Rows.Count() - 1
End If
showData(index)
End Sub
...