LaDissertation.com - Dissertations, fiches de lectures, exemples du BAC
Recherche

Connection Base de donnée avec vb.net

Cours : Connection Base de donnée avec vb.net. Recherche parmi 298 000+ dissertations

Par   •  13 Janvier 2020  •  Cours  •  682 Mots (3 Pages)  •  413 Vues

Page 1 sur 3

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

...

Télécharger au format  txt (2.9 Kb)   pdf (36.7 Kb)   docx (8.6 Kb)  
Voir 2 pages de plus »
Uniquement disponible sur LaDissertation.com