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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| Imports System
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Private conn As OleDbConnection
Private cmd As OleDbCommand
Private da As OleDbDataAdapter
Private ds As New DataSet
Private dt As DataTable
Private strconn As String
Private sql, s1 As String
Sub myconnection()
conn = New OleDbConnection
conn.ConnectionString = strconn
cmd = New OleDbCommand(sql)
da = New OleDbDataAdapter(cmd)
cmd.Connection() = conn
Try
conn.Open()
Catch ex As OleDbException
MsgBox(ex.Message)
End Try
End Sub
Sub affichage()
strconn = "provider=microsoft.jet.OleDB.4.0;" & "data source=D:\raport.mdb"
sql = "SELECT tabraport.* FROM tabraport"
myconnection()
da.Fill(ds, "tabraport")
dt = ds.Tables("tabraport")
DataGridView1.DataSource = ds.Tables("tabraport")
conn.Close()
End Sub
Sub combo()
sql = "SELECT DONNEE.* FROM DONNEE "
myconnection()
da.Fill(ds, "DONNEE")
dt = ds.Tables("DONNEE")
Comb1.DataSource = ds.Tables("DONNEE")
Comb1.DisplayMember = "TYPE DONNEE"
Comb1.SelectedIndex = 0
conn.Close()
''''''''''''''''''''''''''''''''''''''''''''''''''
sql = "SELECT TRANSTYPAGE.* FROM TRANSTYPAGE"
myconnection()
da.Fill(ds, "TRANSTYPAGE")
dt = ds.Tables("TRANSTYPAGE")
Comb2.DataSource = ds.Tables("TRANSTYPAGE")
Comb2.DisplayMember = "TYPETRANSTYPAGE"
Comb2.SelectedIndex = 0
conn.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO*: cette ligne de code charge les données dans la table 'RaportDataSet.tabraport'. Vous pouvez la déplacer ou la supprimer selon vos besoins.
Me.TabraportTableAdapter.Fill(Me.RaportDataSet.tabraport)
affichage()
combo()
End Sub
Private Sub cmdajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdajouter.Click
strconn = "provider=microsoft.jet.OleDB.4.0;" & "data source=D:\raport.mdb"
sql = "INSERT INTO tabraport (Nom,Donnée,Type) VALUES ('" & TXT1.Text & "','" & Comb1.Text & "','" & Comb2.Text & "')"
myconnection()
da.Fill(ds, "tabraport")
dt = ds.Tables("tabraport")
ds.Clear()
conn.Close()
affichage()
combo()
End Sub |
Partager