windows表单应用程序与在线数据库 [英] windows form application with online database

查看:101
本文介绍了windows表单应用程序与在线数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个小应用程序,它编辑图像,我想存储它并从数据库中检索,我有一个在线数据库,每件事情都很好但上传和检索图像太慢,我怎么能让它工作快速。

连接代码

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 ?

推荐答案




Con.ConnectionString = gszStr
Con.Open()
Catch ex As 异常
MsgBox( 未连接到Internet,MsgBoxStyle.Information)

结束 尝试

结束 Sub
" 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 ?


这篇关于windows表单应用程序与在线数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆