Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Multiple connections to access DB

Posted on 2004-09-22
4
Medium Priority
?
170 Views
Last Modified: 2010-04-23
I will post some code here.
I am creating multi threads to help my process go along faster.

When I am filling one of my datagrid i am getting an error stating:connection open and executing

I feel that this error is because it is creating another connection to the database.

How does one allow multiple connections to the same access database at the same time.  The connections are only  SELECT queries no update, delete, or adds.

This is going to be on a server with muliple users connecting



    Public Sub frm_search_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'hide the child button
        hide_child()
        'hide the parent button
        hide_parent()
        'hide the gif
        hideimage()
        'check online
        Online_Offline()


        ' On page load add databinding for the spins desc
        Me.spins_txt.DataBindings.Add("text", Me.DbDataSet.Tables(0), "DESC")

        ' lets hide columns from view in our DataSet
        Me.DataGrid.TableStyles(0).GridColumnStyles("DESC").Width = 0
        'Me.DataGrid.TableStyles(0).GridColumnStyles("Image").Width = 0
        Me.DataGrid.TableStyles(0).GridColumnStyles("Part_Num").Width = 10


        If online = True Then
            online_txt.Text = "ONLINE"
        Else
            online_txt.Text = "OFFLINE"

        End If

        Fill_Child_dataview()
    End Sub



 Public Sub Fill_Child_dataview()
        Dim workthread2 As New System.Threading.Thread(AddressOf fillchilddata)
        workthread2.Start()
    End Sub

    Private Sub fillchilddata()
        'Application.DoEvents()
        Me.OleDbDataAdapter2.Fill(Me.Childdataset)
            End Sub





Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Not filterStr.Equals(String.Empty) Then

            If Not (search_txt.Text.Equals(String.Empty)) Then
                cmdText &= " AND T_PARTS.PRODUCT_CODE IN (" & filterStr & ")"
            Else
                cmdText &= " WHERE T_PARTS.PRODUCT_CODE IN (" & filterStr & ")"
            End If
        End If

        ' Set the SelectCommand to the newly constructed query
        Me.OleDbSelectCommand1.CommandText = cmdText
        'Execute the query
        ' create multi thread
        StartDoWork()
    End Sub


  Private Sub StartDoWork()
        Dim workThread As New System.Threading.Thread(AddressOf DoWork)
        workThread.Start()
    End Sub

    Private Sub DoWork()

        showimage()

        DbDataSet.Clear()
        Application.DoEvents()
        Me.OleDbDataAdapter1.Fill(Me.DbDataSet)            <====================This is where the error happens
        '// Do your work here
        hideimage()

    End Sub



Public Sub Start_PRNT_CHLD()
        Dim workthread1 As New System.Threading.Thread(AddressOf Do_PRNT_CHLD)
        workthread1.Start()
    End Sub

    Private Sub Do_PRNT_CHLD()
        Application.DoEvents()
       ' look_for_parent()
        look_for_child()
    End Sub



 Public Sub look_for_child()

        Dim drv1 As DataRowView 'Data Row View object to query DataView object

        'Associate the dataview
        Dim dataview1 As New DataView
        dataview1.Table = Me.Childdataset.Tables("T_PRNT_CHLD")

        'Apply a filter against any of the columns in View...
        ' dataview.RowFilter = "[CHLD] Like '" & pnmain & "'"

        For Each drv1 In dataview1
            _pnmain1 = CStr(drv1("PRNT"))

            If _pnmain1 = pnmain Then
                show_child()
                Exit For
            Else
                hide_child()
            End If
        Next
    End Sub
0
Comment
Question by:malanois
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 34

Accepted Solution

by:
flavo earned 2000 total points
ID: 12127814
Is it because both your OleDbDataAdapter1 and OleDbSelectCommand1 are using the same connection...
0
 

Author Comment

by:malanois
ID: 12132365
hmmmm......

I will try a different connection and let you know.
0
 

Author Comment

by:malanois
ID: 12142813
that was it thanks
0
 
LVL 34

Expert Comment

by:flavo
ID: 12148282
Cheers mate.

Glad its working now!

Dave
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question