الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف يتم إدراج الصور من قاعدة البيانات Access XP

مغلق
بدأه الشهاب الحارق في 16 سبتمبر 2003 · 5 رد · 1,853 مشاهدة · في Microsoft Visual Basic.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

كيف يتم إدراج الصور من قاعدة البيانات Access XP إلى VB.NET

وكيف يتم العكس بحيث نحفظ الصور التي لدينا في VB.NET إلى اكسس

السؤال الأخير كيف يتم حفظ الصور في أكسس على أنها linked وليست Embedded

و جزاكم الله خيرا

في المثال يتضح المقال

#2

السلام عليكم

توصلت للحل والله الحمد والمنه

طريقة حفظ الصور في Access DataBase تكون كالتالي

طريقة إحضار الصورة

With OFD

            'Your custom Title
            .Title = "صندوق الصور"

            'Start From This Directory
            .InitialDirectory = Application.StartupPath & "\pic"

            'Filtering to show only the Image With jpg & gif
            .Filter = "Image Files(*.JPG;*.GIF) |*.jpg;*.gif"

            'IF the picture Picked Up Then
            If .ShowDialog = DialogResult.OK Then
                'Load picture into PictureBox
                Me.PB.Image = Image.FromFile(.FileName)
            End If
            lblFilePath.Text = .FileName
        End With

طريقة حفظ الصورة

Dim ms As New MemoryStream
        PB.Image.Save(ms, PB.Image.RawFormat)
        Dim image() As Byte = ms.GetBuffer
        ms.Close()
        Try

            Dim arrFilename() As String = _
            Split(lblFilePath.Text, "\")
            arrFilename.Reverse(arrFilename)

            Dim sqlStatement As String = _
    ("INSERT INTO myTable(FileName,Picture)" & _
    "VALUES(?,?)")
            Dim cmd As New OleDbCommand(sqlStatement, Cnn)
            With cmd
                .Parameters.Add(New OleDbParameter("@FileName", _
           OleDbType.WChar, 50)).Value = arrFilename(0)
                .Parameters.Add(New OleDbParameter("@Picture", _
            OleDbType.VarBinary)).Value = image

            End With

         
            Cnn.Open()
            cmd.ExecuteNonQuery()
            Cnn.Close()
        Catch ex As Exception
            MsgBox(ex.Message)
            Exit Sub
        End Try

طريقة عرض الصورة في picture box كالتالي

Try
 Dim i As Integer
            i = CType(Me.BindingContext(Ds1, "myTable").Position, Integer)
            Dim arrPicture() As Byte = _
             CType(Ds1.Tables(0).Rows(i)("Picture"), _
             Byte())
            Dim ms As New MemoryStream(arrPicture)

            With PB
                .Image = Image.FromStream(ms)
                .SizeMode = PictureBoxSizeMode.StretchImage
                .BorderStyle = BorderStyle.Fixed3D
            End With

            lblFileName.Text = _
             Ds1.Tables(0).Rows(i)("FileName").ToString

        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

في المثال يتضح المقال

#3

أليس من الأفضل عمل مجلد خارجى توضع فيه كل الصور ويتم استعداء الصورة المطلوبة مع كل سجل وتوضع فى PictureBox

لأنه بذلك حجم قاعدة البيانات سيكون كبير جدا مما يصعب التعامل معها

#4

السلام عليكم

بالضبط بارك الله فيك

هذا الذي كنت ولا زلت اسأل عنه

عندك اخي مثال على ذلك بالـ visual basic .net ؟

في المثال يتضح المقال

#5

بسم الله الرحمن الرحيم

شكرا بارك الله فيك

#6

ذا هو كود مسار الصورة وعرضها في PictureBox ..

اذا كنت ت

With cmdRet
                .CommandType = CommandType.Text
                .CommandText = "SELECT PIC FROM TABLE"
                .Connection = CON
            End With

            rd = cmdRet.ExecuteReader

While rd.Read
txtPicURL.Text = rd("PIC").ToString
End While

If txtPicURL.Text <> "" Then
                pbLogo.Image = Image.FromFile(Me.txtPicURL.Text)
            Else
                pbLogo.Image = Nothing

            End If

ان شاء الله يكون الكود واضح ...

وانا جاهز لأي استفسار

هذا الموضوع مغلق.

مواضيع مشابهة