IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

gestion des photos par Access.


Sujet :

VB.NET

  1. #1
    Nouveau membre du Club
    Inscrit en
    Décembre 2008
    Messages
    68
    Détails du profil
    Informations forums :
    Inscription : Décembre 2008
    Messages : 68
    Points : 30
    Points
    30
    Par défaut gestion des photos par Access.
    bonjour
    pour gerer des images dans une base access ,je saisis une référence de l'image dans la base access et en utilisant ado.net je parcoure les images.
    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
    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
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
     
    Imports System
    Imports System.Data
    Imports System.Data.OleDb
    Public Class Form1
        Private Macon As OleDbConnection
        Private CmdPhoto As OleDbCommand
        Private DtAPhoto As OleDbDataAdapter
        Private DsPhoto As DataSet
        Private CmdBuildPhoto As OleDbCommandBuilder
        Private StrSql As String = ""
        Private RowNumber As Integer = 0
        Private Sub BtQuiter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtQuiter.Click
            End
        End Sub
     
        Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Macon = New OleDbConnection
            StrSql = "select * from [les photos]"
            Try
                Macon.ConnectionString = "Provider=Microsoft.jet.oledb.4.0;data source =" & My.Application.Info.DirectoryPath & "\MesPhotos.mdb"
                Macon.Open()
                CmdPhoto = New OleDbCommand(StrSql, Macon)
                DtAPhoto = New OleDbDataAdapter(CmdPhoto)
                DsPhoto = New DataSet
                DtAPhoto.Fill(DsPhoto, "Les Photos")
                If RowNumber < 0 Then Exit Sub
                If RowNumber > DsPhoto.Tables("Les Photos").Rows.Count - 1 Then Exit Sub
                TxtNum.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("numéro").ToString
                TxtNom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Nom").ToString
                TxtPrénom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("prénom").ToString
                Dim monimage = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo").ToString
     
                PicPhoto.Load(My.Application.Info.DirectoryPath & "\Photos\" & DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo"))
            Catch ex As Exception
                MsgBox(ex.Message, vbCritical, "Gestion des Photos")
                Exit Sub
            Finally
                'Macon.Close()
            End Try
     
        End Sub
     
        Private Sub BtMoveFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtMoveFirst.Click
            On Error GoTo err
            RowNumber = 0
            If RowNumber = -1 Then Exit Sub
            TxtNum.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("numéro").ToString
            TxtNom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Nom").ToString
            TxtPrénom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("prénom").ToString
            Dim monimage = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo").ToString
     
            PicPhoto.Load(My.Application.Info.DirectoryPath & "\Photos\" & DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo"))
            Exit Sub
    err:
            GerrerErreur()
        End Sub
     
        Private Sub BtMovePrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtMovePrevious.Click
            On Error GoTo err
            RowNumber -= 1
            If RowNumber = -1 Then Exit Sub
            TxtNum.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("numéro").ToString
            TxtNom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Nom").ToString
            TxtPrénom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("prénom").ToString
            Dim monimage = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo").ToString
            PicPhoto.Load(My.Application.Info.DirectoryPath & "\Photos\" & DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo"))
            Exit Sub
    err:
            GerrerErreur()
        End Sub
     
        Private Sub BtMoveNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtMoveNext.Click
            On Error GoTo err
            RowNumber += 1
            If RowNumber > DsPhoto.Tables("Les Photos").Rows.Count - 1 Then Exit Sub
            TxtNum.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("numéro").ToString
            TxtNom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Nom").ToString
            TxtPrénom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("prénom").ToString
            Dim monimage = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo").ToString
            PicPhoto.Load(My.Application.Info.DirectoryPath & "\Photos\" & DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo"))
            Exit Sub
    err:
            GerrerErreur()
        End Sub
     
        Private Sub BtMoveLast_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtMoveLast.Click
            On Error GoTo err
            RowNumber = DsPhoto.Tables("Les Photos").Rows.Count - 1
            If RowNumber > DsPhoto.Tables("Les Photos").Rows.Count - 1 Then Exit Sub
            TxtNum.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("numéro").ToString
            TxtNom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Nom").ToString
            TxtPrénom.Text = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("prénom").ToString
            Dim monimage = DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo").ToString
     
            PicPhoto.Load(My.Application.Info.DirectoryPath & "\Photos\" & DsPhoto.Tables("Les Photos").Rows(RowNumber).Item("Photo"))
            Exit Sub
    err:
            GerrerErreur()
        End Sub
        Sub GerrerErreur()
            PicPhoto.Load(My.Application.Info.DirectoryPath & "\Photos\Error.jpg")
        End Sub
    End Class
    j'attends vous commentaires pour m'améliorer et merçi.
    Fichiers attachés Fichiers attachés

  2. #2
    Membre expérimenté Avatar de hunteshiva
    Homme Profil pro
    Chef de projet en SSII
    Inscrit en
    Février 2010
    Messages
    1 069
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Chef de projet en SSII
    Secteur : Industrie

    Informations forums :
    Inscription : Février 2010
    Messages : 1 069
    Points : 1 455
    Points
    1 455
    Par défaut
    Bonjour,

    j'attends vous commentaires pour m'améliorer
    c'est pas une vrai problématique ça


    En ce qui concerne ton code, tu ne commente rien.... c'est pas super.
    La ça va parce-que ton code est tout petit, mais si tu fait 300-400 lignes, ne nous demande pas de regarder le code

    Ensuite il y a un soucis, dans ton appli.
    Quand tu arrive au dernier enregistrement, tu a la possibilité de continuer...
    Même si tu n'a rien, tu peux continuer... C'est sur tu n'a pas d'erreurs mais c'est un bug pour moi.

  3. #3
    Membre éprouvé Avatar de yonpo
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2010
    Messages
    617
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2010
    Messages : 617
    Points : 947
    Points
    947
    Par défaut
    Et les On Error Goto...
    On Erro Goto vient de vb6 et il faut oublier. Utilise Try/Catch comme tu l'a fait avant.

Discussions similaires

  1. Access & la gestion des photos
    Par orion_ dans le forum VBA Access
    Réponses: 5
    Dernier message: 28/05/2009, 10h30
  2. gestion des photos par formulaire
    Par jeck dans le forum IHM
    Réponses: 23
    Dernier message: 12/04/2006, 15h12
  3. A l'attention de CAFEINE - gestion des photos
    Par cadomalo dans le forum Access
    Réponses: 3
    Dernier message: 23/01/2006, 15h59
  4. Gestion des photos - Taille de la base
    Par le géologue dans le forum Access
    Réponses: 4
    Dernier message: 27/09/2005, 17h54

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo