begin process at 2010 03 19 17:13:33
  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 :
Aucune note
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é :2 325 / 291

Auteur : othinakiway

Ecrire un message privé
Commentaire sur cette source (4)
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 avec Zip Source .NET (Dotnet) SÉRIALISTION - DÉSERIALISATION DE TABLEAUX ET COLLECTIONS par AlexMS
Source avec Zip Source avec une capture Source .NET (Dotnet) [LAMEGRID] SÉRIALISATION - DÉSERIALISATION par AlexMS
Source avec Zip Source avec une capture Source .NET (Dotnet) INSERER TOUT TYPE DE FICHIERS DANS ORACLE EN VB.NET par SKY32
Source avec Zip Source avec une capture Source .NET (Dotnet) ENVOYER DES EMAILS AVEC PIECES JOINTES EN EXÉCUTANT BLAT par mays
Source avec Zip Source avec une capture Source .NET (Dotnet) PILOTER DES AFFICHEURS 7 SEGMENTS À PARTIR DU PORT SÉRIE OU ... par mays

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture LE JEU DU PENDU par xinewz
Source avec Zip Source avec une capture Source .NET (Dotnet) INSERER TOUT TYPE DE FICHIERS DANS ORACLE EN VB.NET par SKY32
Source avec Zip Source avec une capture RÉPERTOIRE TÉLÉPHONE SIMPLE VB2008 EXPRESS EN LIEN AVEC FICH... par stef68600
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>

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

VB.Net Compacter une BD - ADO - Access [ par JeffC1977 ] Bonjour à tous... J'ai un programme qui utilise ADO.Net et deux Tables Acces. Je me demande si c'est possible de coder afin de compacter les table VB.Net Requête SQL pour ADO.Net [ par MagDix ] BonjourJe susi entrain d'essayé de faire une Requête SQL toute simple afin de mettre tout les lignes qui contienne un astérix dans une certain colonne VB.Net ADO.Net et Excel Connection [ par MagDix ] Salut J'essais de me créer un appli qui utilise ADO.Net et un fichier EXcel et j'ai certaines difficultées. L'une d'entre elle est la connection e Objet datagrid et ADO dans VB 6.0 [ par Tamlaclass ] Bonjour, je suis entrain de monter un programme VB 6 avec une base de donnes Access 2007. J'ai un datagrid dans une form nomme 'GrdDisplay' avec des c VB.Net ADO.Net Si donnée absente dans BD [ par MagDix ] Bonjour, Je cherche unmoyen pour coder (avec ADO.Net et VB.Net) une facon pour que si je cherche une valeur dans ma BDet qu'elle est inexistante, al VB + ADO - Champs de type Varchar [ par zet63 ] Bonjour a tous,Je developpe un outils en vb.net + ado qui doit réorganiser des bases access 95.Ces bases sont ensuite utilisées par un logiicel tiers VB.Net DataGrid ADO Valeur nul ??? [ par JeffC1977 ] Salut à tous...J'utilsie un DataGrid et j'ai réussi à affichier ma table Acces dans le DataGrid.Le seul problème est que j'ai plusieurs cellule vide d VB.Net ADO.Net et Excel ??? [ par MagDix ] Salut... J'aimerais savoir Je sais que ADO.Net fonctionne avec VB 2005 .Net. J'ai utilisé ce code et je saisi assez ce code. Toutefois j'aimerai VB.Net Ado Requête SQL Problème [ par JeffC1977 ] Salut..J'ai un problème avec un requête simple SQL.. J'utilise VB.Net et ADO.Net.Cette requête fonctionnait correctement jadis et je dois avoir un err


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mars 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728
293031    

Consulter la suite du CalendriCode

Photothèque

 
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 : 6,256 sec (3)

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