Click here to Skip to main content
15,881,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
VB
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
VB
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
VB
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()

      '******************Give save successfull message ***********************
      MsgBox("Values Saved Successfully", MsgBoxStyle.Information)

code is working fine but how to speed up things ?
Posted

1 solution

No, probably not.
The problem is almost certainly the amount of traffic between you and the server via the internet - which is restricted by you connection speed. If this operation is slow, it is likely that your connection speed is just not up to the job, particularly upload which is generally slower than download anyway. Depending on the connection speed and the size of your images, it could take some considerable time to view the images (try looking at large images from the net - they take time to appear for exactly the same reasons)

Using an "open" database on the internet directly is a fairly poor idea from a security point of view anyway, so live with the delay, or find a more local cache from your images. And I really, really hope you have disabled the "SA" account on your SQL server!
 
Share this answer
 
Comments
akjan4 11-May-13 8:29am    
for the same reason above , I decide to save all data to my local database(ms Access) then export it to SQLServer, now i need to know, how to do it.
OriginalGriff 11-May-13 8:43am    
What part is a problem?
akjan4 12-May-13 7:19am    
i crated a local access database, where i store every information,this local database is same as my online Database,now what i have done so far is that, im copying Access data to online database using sqlbulkcopy, work fine on normal data, but during copying image files from access to online database it work too slow, i declared the batch size to 10, still taking too much time to write image on online Database, what to do ??? please help me out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900