Application Hang during OleDbDataAdapter.Fill

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcolino

    Application Hang during OleDbDataAdapter.Fill

    Hi all,
    I'm using this code to export entire table from access to xml file.

    DScmdXML = New OleDb.OleDbComm and(sqlXML, conn)
    DScmdXML = New OleDb.OleDbData Adapter(cmdXML)
    DScmdXML.Fill(D SXML, sTableName)
    DSXML.WriteXml( sFileName, XmlWriteMode.Wr iteSchema)
    Dim xmlSW2 As System.IO.Strea mWriter = New
    System.IO.Strea mWriter(sFullPa th)
    DSXML.WriteXml( xmlSW2, XmlWriteMode.Wr iteSchema)
    xmlSW2.Flush()
    xmlSW2.Close()

    During DScmdXML.Fill(D SXML, sTableName) command the application hangs.
    In some case I need to export big tables, I would like to add a
    progress bar during the process, but the bar does not work and
    application seems frezed. I tried to add a
    System.Windows. Forms.Applicati on.DoEvents(), but nothing change.

    Do you have any suggestion?

    Many Thanks
  • =?Utf-8?B?TG9yZCBHb29zRmFuY2l0bw==?=

    #2
    Re: Application Hang during OleDbDataAdapte r.Fill

    Hi!.
    I have one question. Where be declarate this procedure?

    AsyncProcess = New AsynchMethodInv oker(AddressOf Me.DoSomething)

    I can see that AsynchMethodInv oker(...) is call... but where be declarate?

    Tank.


    "Michel Posseth [MCP]" wrote:
    "Marcolino" <marco.pozzuolo @gmail.comschre ef in bericht
    news:69281328-905c-48d8-94ed-463dbe490b1e@d2 1g2000prf.googl egroups.com...
    Hi all,
    I'm using this code to export entire table from access to xml file.

    DScmdXML = New OleDb.OleDbComm and(sqlXML, conn)
    DScmdXML = New OleDb.OleDbData Adapter(cmdXML)
    DScmdXML.Fill(D SXML, sTableName)
    DSXML.WriteXml( sFileName, XmlWriteMode.Wr iteSchema)
    Dim xmlSW2 As System.IO.Strea mWriter = New
    System.IO.Strea mWriter(sFullPa th)
    DSXML.WriteXml( xmlSW2, XmlWriteMode.Wr iteSchema)
    xmlSW2.Flush()
    xmlSW2.Close()

    During DScmdXML.Fill(D SXML, sTableName) command the application hangs.
    In some case I need to export big tables, I would like to add a
    progress bar during the process, but the bar does not work and
    application seems frezed. I tried to add a
    System.Windows. Forms.Applicati on.DoEvents(), but nothing change.

    Do you have any suggestion?

    Many Thanks
    >
    >
    Hello ,
    >
    If you want a responsive UI, while your program is verry bussy , you might
    investigate asynchrounous processing ( multi threading )
    >
    i have once written some examples for this newsgroup how to acomplish this
    in an easy way with Async delegates
    >
    here is one :
    >
    take a form throw 2 buttons on it and a progressbar
    >
    >
    call the progressbar pbmain
    >
    >
    now copy paste this :
    >
    >
    Imports System.Threadin g
    Public Class Form1
    Private Mvar_Cancell As Boolean
    Friend Property Cancell() As Boolean
    Get
    Return Mvar_Cancell
    End Get
    Set(ByVal value As Boolean)
    Mvar_Cancell = value
    Me.Button1.Enab led = value
    End Set
    End Property
    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
    Me.Cancell = False
    With pbMain
    .Value = 0
    .Maximum = 100
    .Minimum = 0
    End With
    >
    >
    Dim AsyncProcess As New AsynchMethodInv oker(AddressOf Me.pbLoop)
    AsyncProcess.Be ginInvoke(Nothi ng, Nothing)
    >
    >
    AsyncProcess = New AsynchMethodInv oker(AddressOf Me.DoSomething)
    AsyncProcess.Be ginInvoke(Nothi ng, Nothing)
    >
    >
    End Sub
    Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button2.Click
    Cancell = True
    End Sub
    >
    >
    Private Sub DoSomething()
    Do While Not Me.Cancell
    Debug.WriteLine ("hello world")
    Loop
    End Sub
    Delegate Sub CrossThreadInvP araMB(ByVal val As Integer)
    Private Sub pbLoop()
    Dim i As Integer
    Do While Not Me.Cancell
    Thread.Sleep(50 )
    i += 1
    If i = 101 Then i = 0
    SetPbValue(i)
    Loop
    i = 100
    SetPbValue(i)
    End Sub
    Delegate Sub AsynchMethodInv oker()
    Public Sub SetPbValue(ByVa l Count As Integer)
    If Me.pbMain.Invok eRequired Then
    Dim d As New CrossThreadInvP araMB(AddressOf SetPbValue)
    Try
    Me.Invoke(d, New Object() {Count})
    Catch ex As Exception
    >
    >
    End Try
    Else
    Me.pbMain.Value = Count
    End If
    End Sub
    Private Sub Form1_FormClosi ng(ByVal sender As Object, ByVal e As
    System.Windows. Forms.FormClosi ngEventArgs) Handles Me.FormClosing
    Me.Cancell = True
    End Sub
    End Class
    >
    >
    i hope this gives you all an idea in what i mean ,,, the method that is now
    updating the progressbar runs in a seperate thread to make it even nicer i
    run another worker thread wich prints hello world statements to the debug
    window
    >
    >
    these threads can comunicate to the progressbar through the SetPbValue
    method
    >
    see for more :
    >

    >
    >
    >
    Michel
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >

    Comment

    Working...