i have created an small application which edit image, i want to store it and retrieve from database, i have an online database, every thing is working fine but uploading and retrieval of image is too slow , how can i make it work fast.
connection code
Try
Dim gszStr As String
gszStr = "Data Source =server ip;database=dbName ;UID=@# ;Password=$#$#$"
Con.ConnectionString = gszStr
Con.Open()
Catch ex As Exception
MsgBox("Not Connected To Internet", MsgBoxStyle.Information)
End Try
End Sub
Retrieval Code
Try
Dim ct1 As New SqlClient.SqlCommandBuilder
Dim tmpds As New DataSet
Dim tmpda As New SqlDataAdapter
tmpda.SelectCommand = New SqlCommand(sql, Con)
tmpda.Fill(tmpds)
If tmpds.Tables(0).Rows.Count <> 0 Then
PF_ShowImage(tmpds.Tables(0).Rows(0).Item(2))
End If
Catch ex As Exception
MsgBox("Server Not Responding", MsgBoxStyle.Critical)
End Try
Upload code
Dim Sqlstr As String
Dim daH As New SqlDataAdapter
Dim data() As Byte = PF_SaveImage()
PictureBox1.Image.Save("C:\NewFileName.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
Sqlstr = ("Insert into TestImage Values(@Img)")
daH.InsertCommand = New SqlCommand(Sqlstr, Con)
daH.InsertCommand.Parameters.Add(New SqlParameter("@Img", SqlDbType.Image)).Value = data
daH.InsertCommand.ExecuteNonQuery()
MsgBox("Values Saved Successfully", MsgBoxStyle.Information)
code is working fine but how to speed up things ?