begin process at 2012 02 16 16:21:47
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

VB.NET

 > CLASS D'ACCÈS AU BASE DE DONNÉES OLEDB

CLASS D'ACCÈS AU BASE DE DONNÉES OLEDB


 Information sur la source

Note :
8 / 10 - par 1 personne
8,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :VB.NET Source .NET ( DotNet ) Classé sous :vb, ado, OLEDB Niveau :Débutant Date de création :20/05/2009 Date de mise à jour :31/05/2009 22:25:57 Vu / téléchargé :4 028 / 476

Auteur : othinakiway

Ecrire un message privé
Commentaire sur cette source (5)
Ajouter un commentaire et/ou une note

 Description

Voila ma première source, c'est une classe d'accès au base de données OLEDB, elle comporte les méthodes d'ordre général "mise à jour","création des tables","remplissage" et "création des relations".. en utilisant les deux mode de connection, surtout le mode déconnecté... je serai très heureux que qqun puisse se servir de cette classe.
toutes vos remarques ou critiques instructives seront les bienvenues

Source

  • Imports System.Data.OleDb
  • Public Class AccessDataBase
  • Private ds As DataSet
  • Private dv As DataView
  • Private dt As DataTable
  • Private da As OleDbDataAdapter
  • Private das As Dictionary(Of String, OleDbDataAdapter)
  • Private con As OleDbConnection
  • Private cmd As OleDbCommand
  • Private reader As OleDbDataReader
  • Private cmdBuilder As OleDbCommandBuilder
  • Public Sub New(ByVal strCon As String)
  • ds = New DataSet
  • dv = New DataView
  • da = New OleDbDataAdapter
  • das = New Dictionary(Of String, OleDbDataAdapter)
  • con = New OleDbConnection(strCon)
  • cmd = New OleDbCommand("", con)
  • dt = New DataTable
  • cmdBuilder = New OleDbCommandBuilder
  • End Sub
  • Public Function getDataSet() As DataSet
  • Return ds
  • End Function
  • Public Function getConnection() As OleDbConnection
  • Return con
  • End Function
  • Public Sub creerTable(ByVal nomTable As String)
  • Dim adapter As New OleDbDataAdapter
  • executeRequete("select * from " & nomTable, adapter)
  • adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
  • adapter.Fill(ds, nomTable)
  • das.Add(nomTable, adapter)
  • End Sub
  • #Region "Méthodes de mise à jour"
  • Public Sub ajouter(ByVal nomTable As String, ByVal id As Object(), ByVal params As Object())
  • If Not ds.Tables(nomTable).Rows.Contains(id) Then
  • ds.Tables(nomTable).Rows.Add(params)
  • Else
  • MsgBox("Cet enregistrement existe déjà dans la base de données", MsgBoxStyle.Exclamation, "Erreur d'ajour")
  • End If
  • End Sub
  • Public Sub modifier(ByVal nomtable As String, ByVal id As Object(), ByVal params As Object())
  • Dim row As DataRow = Nothing
  • Dim i As Integer
  • If ds.Tables(nomtable).Rows.Contains(id) Then
  • For i = 0 To params.Length - 1
  • row(i) = params(i)
  • Next
  • End If
  • End Sub
  • Public Sub supprimer(ByVal nomTable As String, ByVal id As Object())
  • If ds.Tables(nomTable).Rows.Contains(id) Then
  • ds.Tables(nomTable).Rows.Find(id).Delete()
  • End If
  • End Sub
  • Public Function rechercher(ByVal nomTable As String, ByVal id As Object) As DataRow
  • If ds.Tables(nomTable).Rows.Contains(id) Then
  • Return ds.Tables(nomTable).Rows.Find(id)
  • Else
  • Return Nothing
  • End If
  • End Function
  • Public Function rechercherParFiltration(ByVal nomTable As String, ByVal filtre As Object) As DataRow()
  • If ds.Tables(nomTable).Select(filtre).Count <> 0 Then
  • Return ds.Tables(nomTable).Select(filtre)
  • End If
  • Return Nothing
  • End Function
  • Public Sub enregistrer(ByVal nomTable As String)
  • cmdBuilder = New OleDbCommandBuilder(das(nomTable))
  • das(nomTable).Update(ds.Tables(nomTable))
  • End Sub
  • #End Region
  • #Region "Méthode de remplissage"
  • Public Sub remplir(ByRef grid As DataGrid, ByVal nomTable As String, ByVal filtre As Object, ByVal expressionTri As Object)
  • dv = New DataView(ds.Tables(nomTable))
  • dv.RowFilter = filtre
  • dv.Sort = expressionTri
  • grid.DataSource = dv
  • End Sub
  • Public Sub remplir(ByRef grid As DataGridView, ByVal nomTable As String, ByVal filtre As Object, ByVal expressionTri As Object)
  • dv = New DataView(ds.Tables(nomTable))
  • dv.RowFilter = filtre
  • dv.Sort = expressionTri
  • grid.DataSource = dv
  • End Sub
  • Public Sub remplir(ByRef list As ListControl, ByVal nomTable As String, ByVal filtre As Object, ByVal expressionTri As Object, ByVal indexOfDisplayMember As Integer, ByVal indexOfValueMember As Integer)
  • dv = New DataView(ds.Tables(nomTable))
  • dv.RowFilter = filtre
  • dv.Sort = expressionTri
  • list.DataSource = dv
  • list.DisplayMember = ds.Tables(nomTable).Columns(indexOfDisplayMember).Caption
  • list.ValueMember = ds.Tables(nomTable).Columns(indexOfValueMember).Caption
  • End Sub
  • Public Sub remplir(ByRef grid As DataGrid, ByVal rqst As String)
  • Dim table As New DataTable
  • executeRequete(rqst, table)
  • grid.DataSource = table
  • End Sub
  • Public Sub remplir(ByRef list As ListControl, ByVal rqst As String, ByVal indexOfDisplayMember As Integer, ByVal indexOfValueMember As Integer)
  • Dim table As New DataTable
  • executeRequete(rqst, table)
  • list.DataSource = table
  • list.DisplayMember = table.Columns(indexOfDisplayMember).Caption
  • list.ValueMember = table.Columns(indexOfValueMember).Caption
  • End Sub
  • Public Sub remplir(ByRef grid As DataGridView, ByVal rqst As String)
  • Dim table As New DataTable
  • executeRequete(rqst, table)
  • grid.DataSource = table
  • End Sub
  • #End Region
  • #Region "Requête SQL sans paramètres"
  • Private Sub ouvrir_con()
  • Try
  • con.Open()
  • Catch ex As Exception
  • Throw New Exception
  • End Try
  • End Sub
  • Private Sub fermer_con()
  • con.Close()
  • End Sub
  • Private Function CreerCommande(ByVal rqst As String)
  • Return New OleDbCommand(rqst, con)
  • End Function
  • Public Function executeRequete(ByVal rqst As String) As Object
  • Dim commande As New OleDbCommand
  • commande = CreerCommande(rqst)
  • Try
  • ouvrir_con()
  • Return commande.ExecuteScalar
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Return Nothing
  • Finally
  • fermer_con()
  • End Try
  • End Function
  • Public Sub executeRequete(ByVal rqst As String, ByRef myReader As OleDbDataReader)
  • Dim commande As New OleDbCommand
  • commande = CreerCommande(rqst)
  • Try
  • ouvrir_con()
  • myReader = commande.ExecuteReader
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequete(ByVal rqst As String, ByRef adapter As OleDbDataAdapter)
  • Dim commande As New OleDbCommand
  • commande = CreerCommande(rqst)
  • Try
  • ouvrir_con()
  • adapter = New OleDbDataAdapter(commande)
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequete(ByVal rqst As String, ByRef table As DataTable)
  • Dim adapter As New OleDbDataAdapter
  • executeRequete(rqst, adapter)
  • Try
  • ouvrir_con()
  • table = New DataTable
  • adapter.Fill(table)
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequeteReader(ByVal rqst As String, ByVal table As DataTable)
  • Dim row As DataRow
  • Try
  • ouvrir_con()
  • reader = executeRequete(rqst)
  • While reader.Read
  • row = table.NewRow
  • For i As Integer = 0 To reader.FieldCount - 1
  • row(i) = reader.GetValue(i)
  • Next
  • table.Rows.Add(row)
  • End While
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequete(ByVal rqst As String, ByVal dtSet As DataSet)
  • Try
  • ouvrir_con()
  • cmd = CreerCommande(rqst)
  • da.SelectCommand = cmd
  • da.Fill(dtSet)
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • #End Region
  • #Region "Requête SQL avec paramètres"
  • Private Function CreerCommande(ByVal rqst As String, ByVal params() As OleDbParameter) As OleDbCommand
  • Dim param As OleDbParameter
  • Dim commande As New OleDbCommand
  • commande.CommandText = rqst
  • For Each param In params
  • commande.Parameters.Add(param)
  • Next
  • commande.Connection = con
  • Return commande
  • End Function
  • Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByRef myReader As OleDbDataReader)
  • Dim commande As New OleDbCommand
  • commande = CreerCommande(rqst, params)
  • Try
  • ouvrir_con()
  • myReader = commande.ExecuteReader
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByRef adapter As OleDbDataAdapter)
  • Dim commande As New OleDbCommand
  • commande = CreerCommande(rqst, params)
  • Try
  • ouvrir_con()
  • adapter = New OleDbDataAdapter(commande)
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByRef table As DataTable)
  • Dim adapter As New OleDbDataAdapter
  • executeRequete(rqst, params, adapter)
  • Try
  • ouvrir_con()
  • table = New DataTable
  • adapter.Fill(table)
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequeteReader(ByVal rqst As String, ByVal params() As OleDbParameter, ByVal table As DataTable)
  • Dim row As DataRow
  • Try
  • ouvrir_con()
  • reader = executeRequete(rqst, params)
  • While reader.Read
  • row = table.NewRow
  • For i As Integer = 0 To reader.FieldCount - 1
  • row(i) = reader.GetValue(i)
  • Next
  • table.Rows.Add(row)
  • End While
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByVal dtSet As DataSet)
  • Dim adapter As New OleDbDataAdapter
  • executeRequete(rqst, params, adapter)
  • Try
  • ouvrir_con()
  • adapter.Fill(dtSet)
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Finally
  • fermer_con()
  • End Try
  • End Sub
  • Public Function executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter) As Object
  • cmd = CreerCommande(rqst, params)
  • Try
  • ouvrir_con()
  • Return cmd.ExecuteScalar
  • Catch ex As Exception
  • MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
  • Return Nothing
  • Finally
  • fermer_con()
  • End Try
  • End Function
  • #End Region
  • Public Function getTables(ByVal nomTable As String) As DataTable
  • Return ds.Tables(nomTable)
  • End Function
  • Public Sub etablirRelation(ByVal nomRelation As String, ByVal nomTableParent As String, ByVal nomTableEnfant As String, ByVal nomColParent As String, ByVal nomColEnfant As String)
  • Dim colP As New DataColumn
  • Dim colE As New DataColumn
  • colP = ds.Tables(nomTableParent).Columns(nomColParent)
  • colE = ds.Tables(nomTableEnfant).Columns(nomColEnfant)
  • ds.Relations.Add(New DataRelation(nomRelation, colP, colE))
  • End Sub
  • End Class
Imports System.Data.OleDb
Public Class AccessDataBase
    Private ds As DataSet
    Private dv As DataView
    Private dt As DataTable
    Private da As OleDbDataAdapter
    Private das As Dictionary(Of String, OleDbDataAdapter)
    Private con As OleDbConnection
    Private cmd As OleDbCommand
    Private reader As OleDbDataReader
    Private cmdBuilder As OleDbCommandBuilder
    Public Sub New(ByVal strCon As String)

        ds = New DataSet
        dv = New DataView
        da = New OleDbDataAdapter
        das = New Dictionary(Of String, OleDbDataAdapter)
        con = New OleDbConnection(strCon)
        cmd = New OleDbCommand("", con)
        dt = New DataTable
        cmdBuilder = New OleDbCommandBuilder
        

    End Sub
    Public Function getDataSet() As DataSet
        Return ds
    End Function
    Public Function getConnection() As OleDbConnection
        Return con
    End Function
    Public Sub creerTable(ByVal nomTable As String)
        Dim adapter As New OleDbDataAdapter
        executeRequete("select * from " & nomTable, adapter)
        adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
        adapter.Fill(ds, nomTable)
        das.Add(nomTable, adapter)
    End Sub
#Region "Méthodes de mise à jour"
    Public Sub ajouter(ByVal nomTable As String, ByVal id As Object(), ByVal params As Object())
        If Not ds.Tables(nomTable).Rows.Contains(id) Then
            ds.Tables(nomTable).Rows.Add(params)
        Else
            MsgBox("Cet enregistrement existe déjà dans la base de données", MsgBoxStyle.Exclamation, "Erreur d'ajour")
        End If
    End Sub
    Public Sub modifier(ByVal nomtable As String, ByVal id As Object(), ByVal params As Object())
        Dim row As DataRow = Nothing
        Dim i As Integer
        If ds.Tables(nomtable).Rows.Contains(id) Then
            For i = 0 To params.Length - 1
                row(i) = params(i)
            Next
        End If
    End Sub
    Public Sub supprimer(ByVal nomTable As String, ByVal id As Object())
        If ds.Tables(nomTable).Rows.Contains(id) Then
            ds.Tables(nomTable).Rows.Find(id).Delete()
        End If
    End Sub
    Public Function rechercher(ByVal nomTable As String, ByVal id As Object) As DataRow
        If ds.Tables(nomTable).Rows.Contains(id) Then
            Return ds.Tables(nomTable).Rows.Find(id)
        Else
            Return Nothing
        End If
    End Function
    Public Function rechercherParFiltration(ByVal nomTable As String, ByVal filtre As Object) As DataRow()
        If ds.Tables(nomTable).Select(filtre).Count <> 0 Then
            Return ds.Tables(nomTable).Select(filtre)
        End If
        Return Nothing
    End Function
    Public Sub enregistrer(ByVal nomTable As String)
        cmdBuilder = New OleDbCommandBuilder(das(nomTable))
        das(nomTable).Update(ds.Tables(nomTable))
    End Sub
 
#End Region
#Region "Méthode de remplissage"
    Public Sub remplir(ByRef grid As DataGrid, ByVal nomTable As String, ByVal filtre As Object, ByVal expressionTri As Object)
        dv = New DataView(ds.Tables(nomTable))
        dv.RowFilter = filtre
        dv.Sort = expressionTri
        grid.DataSource = dv
    End Sub
    Public Sub remplir(ByRef grid As DataGridView, ByVal nomTable As String, ByVal filtre As Object, ByVal expressionTri As Object)
        dv = New DataView(ds.Tables(nomTable))
        dv.RowFilter = filtre
        dv.Sort = expressionTri
        grid.DataSource = dv
    End Sub
    Public Sub remplir(ByRef list As ListControl, ByVal nomTable As String, ByVal filtre As Object, ByVal expressionTri As Object, ByVal indexOfDisplayMember As Integer, ByVal indexOfValueMember As Integer)
        dv = New DataView(ds.Tables(nomTable))
        dv.RowFilter = filtre
        dv.Sort = expressionTri
        list.DataSource = dv
        list.DisplayMember = ds.Tables(nomTable).Columns(indexOfDisplayMember).Caption
        list.ValueMember = ds.Tables(nomTable).Columns(indexOfValueMember).Caption
    End Sub
    Public Sub remplir(ByRef grid As DataGrid, ByVal rqst As String)
        Dim table As New DataTable
        executeRequete(rqst, table)
        grid.DataSource = table
    End Sub
    Public Sub remplir(ByRef list As ListControl, ByVal rqst As String, ByVal indexOfDisplayMember As Integer, ByVal indexOfValueMember As Integer)
        Dim table As New DataTable
        executeRequete(rqst, table)
        list.DataSource = table
        list.DisplayMember = table.Columns(indexOfDisplayMember).Caption
        list.ValueMember = table.Columns(indexOfValueMember).Caption
    End Sub
    Public Sub remplir(ByRef grid As DataGridView, ByVal rqst As String)
        Dim table As New DataTable
        executeRequete(rqst, table)
        grid.DataSource = table
    End Sub
#End Region
#Region "Requête SQL sans paramètres"
    Private Sub ouvrir_con()
        Try
            con.Open()
        Catch ex As Exception
            Throw New Exception
        End Try

    End Sub
    Private Sub fermer_con()
        con.Close()
    End Sub
    Private Function CreerCommande(ByVal rqst As String)
        Return New OleDbCommand(rqst, con)
    End Function

    Public Function executeRequete(ByVal rqst As String) As Object
        Dim commande As New OleDbCommand
        commande = CreerCommande(rqst)
        Try
            ouvrir_con()
            Return commande.ExecuteScalar
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
            Return Nothing
        Finally
            fermer_con()
        End Try
    End Function
    Public Sub executeRequete(ByVal rqst As String, ByRef myReader As OleDbDataReader)
        Dim commande As New OleDbCommand
        commande = CreerCommande(rqst)
        Try
            ouvrir_con()
            myReader = commande.ExecuteReader
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequete(ByVal rqst As String, ByRef adapter As OleDbDataAdapter)
        Dim commande As New OleDbCommand
        commande = CreerCommande(rqst)
        Try
            ouvrir_con()
            adapter = New OleDbDataAdapter(commande)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequete(ByVal rqst As String, ByRef table As DataTable)
        Dim adapter As New OleDbDataAdapter
        executeRequete(rqst, adapter)
        Try
            ouvrir_con()
            table = New DataTable
            adapter.Fill(table)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequeteReader(ByVal rqst As String, ByVal table As DataTable)
        Dim row As DataRow
        Try
            ouvrir_con()
            reader = executeRequete(rqst)
            While reader.Read
                row = table.NewRow
                For i As Integer = 0 To reader.FieldCount - 1
                    row(i) = reader.GetValue(i)
                Next
                table.Rows.Add(row)
            End While
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequete(ByVal rqst As String, ByVal dtSet As DataSet)
        Try
            ouvrir_con()
            cmd = CreerCommande(rqst)
            da.SelectCommand = cmd
            da.Fill(dtSet)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
#End Region
#Region "Requête SQL avec paramètres"
    Private Function CreerCommande(ByVal rqst As String, ByVal params() As OleDbParameter) As OleDbCommand
        Dim param As OleDbParameter
        Dim commande As New OleDbCommand
        commande.CommandText = rqst
        For Each param In params
            commande.Parameters.Add(param)
        Next
        commande.Connection = con
        Return commande
    End Function
    Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByRef myReader As OleDbDataReader)
        Dim commande As New OleDbCommand
        commande = CreerCommande(rqst, params)
        Try
            ouvrir_con()
            myReader = commande.ExecuteReader
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByRef adapter As OleDbDataAdapter)
        Dim commande As New OleDbCommand
        commande = CreerCommande(rqst, params)
        Try
            ouvrir_con()
            adapter = New OleDbDataAdapter(commande)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByRef table As DataTable)
        Dim adapter As New OleDbDataAdapter
        executeRequete(rqst, params, adapter)
        Try
            ouvrir_con()
            table = New DataTable
            adapter.Fill(table)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequeteReader(ByVal rqst As String, ByVal params() As OleDbParameter, ByVal table As DataTable)
        Dim row As DataRow
        Try
            ouvrir_con()
            reader = executeRequete(rqst, params)
            While reader.Read
                row = table.NewRow
                For i As Integer = 0 To reader.FieldCount - 1
                    row(i) = reader.GetValue(i)
                Next
                table.Rows.Add(row)
            End While
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Sub executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter, ByVal dtSet As DataSet)
        Dim adapter As New OleDbDataAdapter
        executeRequete(rqst, params, adapter)
        Try
            ouvrir_con()
            adapter.Fill(dtSet)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
        Finally
            fermer_con()
        End Try
    End Sub
    Public Function executeRequete(ByVal rqst As String, ByVal params() As OleDbParameter) As Object
        cmd = CreerCommande(rqst, params)
        Try
            ouvrir_con()
            Return cmd.ExecuteScalar
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Erreur")
            Return Nothing
        Finally
            fermer_con()
        End Try
    End Function
#End Region


    Public Function getTables(ByVal nomTable As String) As DataTable
        Return ds.Tables(nomTable)
    End Function
    Public Sub etablirRelation(ByVal nomRelation As String, ByVal nomTableParent As String, ByVal nomTableEnfant As String, ByVal nomColParent As String, ByVal nomColEnfant As String)
        Dim colP As New DataColumn
        Dim colE As New DataColumn
        colP = ds.Tables(nomTableParent).Columns(nomColParent)
        colE = ds.Tables(nomTableEnfant).Columns(nomColEnfant)
        ds.Relations.Add(New DataRelation(nomRelation, colP, colE))
    End Sub


End Class

 Conclusion

Ce code est une collection assez complète de méthodes pour gérer l'accès à la BD.

 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

23 mai 2009 01:33:24 :
J'ai améliorer la classe en ajoutant autre méthodes en mode connécté
23 mai 2009 01:40:38 :
g mis un zipfil
31 mai 2009 22:25:58 :
j'ai améliorer la classe, en ajouter des méthodes et en mettant à jour d'autres.. enjoy :D !!

 Sources de la même categorie

Source .NET (Dotnet) MODIFICATION DATE DE WINDOWS EN VB.NET ET VBA par us_30
Source avec Zip Source avec une capture Source .NET (Dotnet) ENVOI DE MAIL AVEC PIÈCE JOINTE par EhJoe
Source .NET (Dotnet) AMUSONS NOUS AVEC UN LABEL ^^ par Adn56
Source avec Zip Source avec une capture Source .NET (Dotnet) UN NAVIGATEUR INTERNET EN VB.NET par azrti
Source avec Zip Source .NET (Dotnet) CONVERSION DE DEVISE MONAITAIRE VIA UN SERVICE WEB par bigmonkey7

 Sources en rapport avec celle ci

Source avec Zip TRAVAILLER AVEC MYSQL par grandzebu
Source avec Zip Source avec une capture Source .NET (Dotnet) UN NAVIGATEUR INTERNET EN VB.NET par azrti
Source avec Zip Source avec une capture VISUAL BASIC ET MICROPROCESSEUR MBED par ccllee
Source avec Zip Source avec une capture ANALYSE DES INCIDENTS SUR LES RÉSEAUX MT par karamimed
Source avec Zip TREEVIEW CONNECTÉ À UNE BD UTILISANT LE CLICK DROIT DE LA SO... par seb

Commentaires et avis

Commentaire de othinakiway le 20/05/2009 12:08:26

Lâchez vos cams ou donnez une note svp........!

Commentaire de othinakiway le 24/05/2009 01:22:40

J'ai besoins de vos avis....

Commentaire de cedleleu le 20/07/2009 11:46:13

Hello,

Je suis nouveau en VB.NET alors je regarde ta source qui à l'air de correspondre avec ce que je veux faire... J'ai une base Access et j'ai 3 TextBox. Je recherche un id via le premier TextBox et je clique ensuite sur "rechercher" afin d'afficher le contenu de 2 autres colonnes comme Nom et Prénom par exemple dans les 2 autres TextBox.
Comment se servir de ton code pour effectuer ce genre de manip ?

Merci

Commentaire de othinakiway le 06/10/2009 12:42:21

bonjour,
je présume que t'as eu réponse à ta question puisque sa fait presque 3 mois depuis que tu l'a posé, mais bon je vais répondre quand même à ta question , même si que la réponse se trouve dans la source:
<code>
dim data as new(chaineDeConnection)

dim row as datarow
row = data.rechercher(textBox1.text)
textBox2.text=row(1)
textBox3.text=row(2)

</code>

Commentaire de IDEFIX76 le 06/01/2011 15:52:17 8/10

Super bible pour travailler Access au corps

Merci

Il manque un petit module pour voir exactement comment toutes les procédures fonctionnent

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Distribution prog avec ADO [ par jray ] J'ai un gros problème: j'ai fait un petit programme de gestion d'entreprise pour gérer clients, fournisseurs, commandes, ... où tout est enregistré da ADO et requery [ par gaetan ] Bonjourje suis en plein developpement d'une appli Vb / SQLserver7 et donc beaucoupd'acces aux données avec des procédures stockées et tablesSeulement image ADO et OLE [ par sappho ] bonjour à tousj'ai stocké dans une base access 2000 des images ( gif, jpeg et bmp) sous forme d'objet OLE. Je désire via VB 6 récupéré mes images et l ADO et sécurité [ par coucou ] Salut à tous,J'ai une base de donnée Access 2.0 et une application VB qui y accède via ADO.Quel qu'un pourrait me donneer une solution afin de pouvoir Précedent et suivant avec ADO et VB [ par Xilikon ] Salut à tous,Je suis en train de programmer un application de base de données en ADO.J'ai ajouté des boutons Précédent et Suivant pour parcourir parmi A tt ceux ki on des prob avec ADO [ par MUS80 ] vous avez fait une appli ==&gt;elle ne fonctionne que sur votre machine ERREUR ADODC,ADO sur une machine vide(ss VB)telecharger le pack5 sur microsoft VB/ADO/ACCESS [ par heritaz ] Dim ADOconnect As ADODB.ConnectionDim ADOrs As ADODB.RecordsetPrivate Sub Command1_Click()Dim ADOconnect As New ADODB.ConnectionDim ADOrs As New ADODB pb d'execution avec ADO [ par LudoBoOz ] J'ai Cree un prog VB avec une base de donnée sous ACCESS etlors de la diffusion du prog sur un poste windows 98n'ayant pas VB lorsque l'on execute le ADO sous Win2000 [ par Lolux ] Bonjour,J'ai un soft qui utilise des ADODB.Connection.J'utilise la chaîne de connexion suivante : Connection1.ConnectionString = _ "Provider=Microsoft


Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,577 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales