Bonjour,
J'ai fai une application Vb de la gestion du personnel sur Microsoft visuel basic 2010 avec Acess 2007, mon probbleme c'est dans la recherche avec ExecuteReader, voila le code dans la classe ou j'ai declaré la variable du ExecuteReader :
et voila la fonction de la recherche :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 Imports System.Data.OleDb Imports System.Windows.Forms Public Class informatique_connection Public mycon As OleDbConnection Public strcon As String Public rdr As OleDbDataReader Public myreq As String Private cmd As OleDbCommand Public Sub connecting_in_informatique() strcon = "provider=Microsoft.ACE.OLEDB.12.0; Data source=C:\Users\user\Documents\bd.accdb" mycon = New OleDbConnection(strcon) mycon.Open() cmd = New OleDbCommand(myreq, mycon) rdr = cmd.ExecuteReader End Sub Public Sub disconnecting_in_informatique() rdr.Close() mycon.Close() End Sub End Class
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 Dim rech As String Dim i As Integer i = 1 rech = InputBox("Entrer le matricule", "Recherche") TextBox1.Text = rech db_informatique.myreq = "SELECT * FROM Perso WHere Matricule = '" & TextBox1.Text & "'" db_informatique.connecting_in_informatique() Do While db_informatique.rdr.Read Me.a1.Text = db_informatique.rdr(0).ToString Me.a2.Text = db_informatique.rdr(1).ToString Me.a3.Text = db_informatique.rdr(2).ToString Me.a4.Text = db_informatique.rdr(3).ToString Me.a5.Text = db_informatique.rdr(4).ToString Me.a6.Text = db_informatique.rdr(5).ToString Me.a7.Text = db_informatique.rdr(6).ToString Me.a8.Text = db_informatique.rdr(7).ToString Me.a9.Text = db_informatique.rdr(8).ToString Me.a12.Text = db_informatique.rdr(9).ToString Me.a10.Text = db_informatique.rdr(10).ToString Me.a11.Text = db_informatique.rdr(11).ToString Me.a13.Text = db_informatique.rdr(12).ToString Me.a14.Text = db_informatique.rdr(13).ToString Me.a15.Text = db_informatique.rdr(14).ToString i = 2 Loop db_informatique.disconnecting_in_informatique() Catch ex As OleDb.OleDbException MessageBox.Show(ex.Message.ToString) End Try End Sub
quelqu'un pourra m'aider??
Merci d'avance...
Partager