I have some problem to save image in sql db and showing the image in crystal report 8.5. i am using visual basic 6.
1º - How can i save a image in SQL?
2º - How can i show in Crystal Report ?
Best Regard's
Printable View
I have some problem to save image in sql db and showing the image in crystal report 8.5. i am using visual basic 6.
1º - How can i save a image in SQL?
2º - How can i show in Crystal Report ?
Best Regard's
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With OpenFileDialog1()
.InitialDirectory = "C:\"
.Filter = "All Files|*.*|Bitmaps|*.bmp|GIFs|*.gif|JPEGs|*.jpg"
.FilterIndex = 4
End With
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
With PictureBox1
.Image = Image.FromFile(Me.OpenFileDialog1.FileName)
.SizeMode = PictureBoxSizeMode.CenterImage
.Visible = True
End With
End If
End Sub
******* on save btn
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
conn.Open()
Dim ms As New MemoryStream
Me.PictureBox1.Image.Save(ms, Me.PictureBox1.Image.RawFormat)
ms.Close() ' Closes the Memory Stream
Try
cmd = New SqlCommand(sql, conn)
Dim strQuery As String = "INSERT INTO TRY( IMG) VALUES(@IMG)"
With cmd
.Parameters.Add(New SqlParameter("@IMG",Type.Image)).Value = arrayImage
End With
cmd.ExecuteNonQuery()
MessageBox.Show("Image and data Saved Into the DataBase")
conn.Close()
Catch ae As SqlException
MessageBox.Show(ae.Message.ToString())
End Try
End Sub
above code for save image in try table( IMG image)
try it
i know how retriev it in pic_box