Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET WinForm
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()
 
        '******************Give save successfull message ***********************
        MsgBox("Values Saved Successfully", MsgBoxStyle.Information)
code is working fine but how to speed up things ?
Posted 10-May-13 21:54pm
akjan4311

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  
Comments
akjan4 at 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 at 11-May-13 8:43am
   
What part is a problem?
akjan4 at 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)

  Print Answers RSS
0 OriginalGriff 295
1 DamithSL 265
2 CPallini 235
3 Maciej Los 190
4 George Jonsson 170
0 OriginalGriff 5,415
1 DamithSL 4,422
2 Maciej Los 3,820
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,911


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 11 May 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100