Click here to Skip to main content
15,885,890 members

windows form application with online database

akjan4 asked:

Open original thread
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 ?
Tags: Visual Basic, Windows Forms

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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