منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب

نسخة كاملة : حفظ صورة علي الجهاز متخزنة في قاعدة البيانات BIT (تم حل المشكلة)
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
بحاول انزل صورة من picture box
بمعني حفظ الصورة علي الجهاز بمسار معين
مش لاقيلها حل [صورة مرفقة: 1f641.png]:(

كود :
Dim temp As New DataTable
       If Convert.ToBoolean(GetValueFromRegistry("WindowsOrSqlServer")) = True Then
           Cnn = New SqlConnection(CnnString)
       ElseIf Convert.ToBoolean(GetValueFromRegistry("WindowsOrSqlServer")) = False Then
           Cnn = New SqlConnection(CnnString1)
       End If
       Cmd = New SqlCommand
       Cmd.CommandText = "Select image1 From PC"
       Cmd.CommandType = CommandType.Text
       Cmd.Connection = Cnn

       Dim ms As New MemoryStream("image1")
       Dim x() As Byte

       pbox.Image = Image.FromStream(ms)
       ms.Dispose()
       ofd.FileName = ""
       ofd.Filter = "Image Files (JPEG,GIF,BMP,PNG,ICO)|*.jpg;*.jpeg;*.gif;*.bmp;*.png;*ico"
       Dim SaveFileAs As New SaveFileDialog
       SaveFileAs.Title = "Save File As"
       SaveFileAs.FileName = ""
       SaveFileAs.Filter = "Image Files (JPEG,GIF,BMP,PNG,ICO)|*.jpg;*.jpeg;*.gif;*.bmp;*.png;*ico"
       If SaveFileAs.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
           pbox.Image.Save(SaveFileAs.FileName, Imaging.ImageFormat.Jpeg)
       End If
تم حل المشكلة الف شكر للعضو الغالي 
كود :
Dim temp As New DataTable
       If Convert.ToBoolean(GetValueFromRegistry("WindowsOrSqlServer")) = True Then
           Cnn = New SqlConnection(CnnString)
       ElseIf Convert.ToBoolean(GetValueFromRegistry("WindowsOrSqlServer")) = False Then
           Cnn = New SqlConnection(CnnString1)
       End If

       Dim r As DataGridViewRow = Me.DataGridView1.CurrentRow
       Dim code = r.Cells("clcode").Value

       Dim cmd As New SqlCommand("Select [image1] From [PC] WHERE [code]=@code", Cnn)
       cmd.Parameters.AddWithValue("@code", code)
       If Cnn.State <> ConnectionState.Open Then Cnn.Open()
       Dim obj As Object = cmd.ExecuteScalar
       Cnn.Close()

       If obj IsNot Nothing AndAlso Not IsDBNull(obj) Then
           Dim stream As New IO.MemoryStream(CType(obj, Byte()))
           Dim img As Image = Image.FromStream(stream)

           Dim SaveFileAs As New SaveFileDialog
           SaveFileAs.Title = "Save File As"
           SaveFileAs.Filter = "Image Files (JPEG)|*.jpg;*.jpeg"
           If SaveFileAs.ShowDialog() = DialogResult.OK Then
               img.Save(SaveFileAs.FileName, Imaging.ImageFormat.Jpeg)
           End If
       End If
[/code]