Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Dataset problem when threading

Dataset problem when threading

Scheduled Pinned Locked Moved Visual Basic
databasecsharpcomsecurity
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    penguin5000
    wrote on last edited by
    #1

    Hi, I'm using VB.NET 2005 Express, and I'm having a go at teaching myself about threading as I want a marquee progress bar displayed on my form whilst it fills a table in a dataset. On my form, I've got a textbox for a database name, and a textbox for simple Select SQL statements. What I'm finding is that when I press 'Go', it populates the DataGridView perfectly, and my progress bar is displayed as I had wanted. However, what I then find is that if I change the contents of the database textbox, or the contents of the SQL textbox, and press 'Go' again, it either doesn't do anything to the DataGridView, or it completely falls over. I'd really appreciate it if you could point me in the right direction to suggest some improvements to the very raw code shown below: Imports System.Data Imports System.Data.OleDb Public Class Form1 Private ds As New DataSet() Private conn As OleDb.OleDbConnection Private WithEvents backGroundWorker1 As New System.ComponentModel.BackgroundWorker ' THREADING REFERENCES ' http://vbcity.com/forums/faq.asp?fid=15&cat=Threading ' http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1386086&SiteID=1 Private Sub FillDataGridView() Dim strDataSource As String = Me.txtDataSource.Text & "@ol_server;" Dim strConnectionString As String = "Provider=Ifxoledbc.2;" & _ "Password=informix;" & _ "User ID=informix;" & _ "Persist Security Info=True;" & _ "Password=informix;" & _ "Data Source=" & strDataSource.ToString conn = New OleDb.OleDbConnection(strConnectionString) Dim ds As New DataSet() backGroundWorker1.RunWorkerAsync() Dim i As Integer For i = 1 To 100 Me.ProgressBar1.Value = i Next End Sub Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click Me.ProgressBar1.Visible = True Me.ProgressBar1.Refresh() FillDataGridView() End Sub Private Sub backGroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backGroundWorker1.DoWork Dim da As New OleDb.OleDbDataAdapter Dim cmd As New OleDb.OleDbCommand conn.Open() cmd.Connection = conn

    P 1 Reply Last reply
    0
    • P penguin5000

      Hi, I'm using VB.NET 2005 Express, and I'm having a go at teaching myself about threading as I want a marquee progress bar displayed on my form whilst it fills a table in a dataset. On my form, I've got a textbox for a database name, and a textbox for simple Select SQL statements. What I'm finding is that when I press 'Go', it populates the DataGridView perfectly, and my progress bar is displayed as I had wanted. However, what I then find is that if I change the contents of the database textbox, or the contents of the SQL textbox, and press 'Go' again, it either doesn't do anything to the DataGridView, or it completely falls over. I'd really appreciate it if you could point me in the right direction to suggest some improvements to the very raw code shown below: Imports System.Data Imports System.Data.OleDb Public Class Form1 Private ds As New DataSet() Private conn As OleDb.OleDbConnection Private WithEvents backGroundWorker1 As New System.ComponentModel.BackgroundWorker ' THREADING REFERENCES ' http://vbcity.com/forums/faq.asp?fid=15&cat=Threading ' http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1386086&SiteID=1 Private Sub FillDataGridView() Dim strDataSource As String = Me.txtDataSource.Text & "@ol_server;" Dim strConnectionString As String = "Provider=Ifxoledbc.2;" & _ "Password=informix;" & _ "User ID=informix;" & _ "Persist Security Info=True;" & _ "Password=informix;" & _ "Data Source=" & strDataSource.ToString conn = New OleDb.OleDbConnection(strConnectionString) Dim ds As New DataSet() backGroundWorker1.RunWorkerAsync() Dim i As Integer For i = 1 To 100 Me.ProgressBar1.Value = i Next End Sub Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click Me.ProgressBar1.Visible = True Me.ProgressBar1.Refresh() FillDataGridView() End Sub Private Sub backGroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backGroundWorker1.DoWork Dim da As New OleDb.OleDbDataAdapter Dim cmd As New OleDb.OleDbCommand conn.Open() cmd.Connection = conn

      P Offline
      P Offline
      Paul Conrad
      wrote on last edited by
      #2

      What specific error are you getting when the app falls over?

      "Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups