473,757 Members | 10,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

background data retrieval

Hi,
I have an application that has a "Data Access Class" and "User Interface
Class".

It is for receiving Purchase Order data from one system and pushing
processed transactions to another system.

The system generally works quite well.
Currently the User interface calls for a refresh of data every 15 minutes
(selectable) and the Data Access Class connects to the DB and retrieves the
data structured to suit the application. During the retrieval it displays
messages informing the User of the various downloads. Each application has
its own Data Access Class. It takes between 30 seconds and 5 minutes to
refresh the data dependant on where the User is located

I have been asked to make the refresh transparent so that the User does not
have to wait for the Data Access Layer to get its data as some site have a
very slow connections to the network.

I am not sure how to achieve this new requirement.
I thought that I could make the Data Access Class a separate application
that loads with the User interface and then periodically retrieves the data
and saves it into a local database file (mdb ?) rather than into the current
Data Set and then have the User Interface asynchronously connect to the
local database and update its records.

I would appreciate any oppinions.

Regards

Doug
Nov 21 '05 #1
10 1666
Hi Doug,

You can execute the loading of your data on a separate thread so that the
form is still responsive to the user, however, you need to be careful that
none of the UI elements work with that data before the data is retrieved.
Once the data is loaded, your data access class should raise an event that
you can handle so you can call the invoke method to marshal the call to the
UI thread. Here's the basic idea (note- this example uses the SQL northwind
database):

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows. Forms.DataGrid
Friend WithEvents TextBox1 As System.Windows. Forms.TextBox
Friend WithEvents Button1 As System.Windows. Forms.Button
Friend WithEvents TextBox2 As System.Windows. Forms.TextBox
Friend WithEvents Button2 As System.Windows. Forms.Button
Friend WithEvents Button3 As System.Windows. Forms.Button
Friend WithEvents Button4 As System.Windows. Forms.Button
Friend WithEvents Button5 As System.Windows. Forms.Button
Friend WithEvents CheckBox1 As System.Windows. Forms.CheckBox
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.DataGrid1 = New System.Windows. Forms.DataGrid
Me.TextBox1 = New System.Windows. Forms.TextBox
Me.Button1 = New System.Windows. Forms.Button
Me.TextBox2 = New System.Windows. Forms.TextBox
Me.Button2 = New System.Windows. Forms.Button
Me.Button3 = New System.Windows. Forms.Button
Me.Button4 = New System.Windows. Forms.Button
Me.Button5 = New System.Windows. Forms.Button
Me.CheckBox1 = New System.Windows. Forms.CheckBox
CType(Me.DataGr id1, System.Componen tModel.ISupport Initialize).Beg inInit()
Me.SuspendLayou t()
'
'DataGrid1
'
Me.DataGrid1.An chor = CType((((System .Windows.Forms. AnchorStyles.To p Or
System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right),
System.Windows. Forms.AnchorSty les)
Me.DataGrid1.Da taMember = ""
Me.DataGrid1.He aderForeColor = System.Drawing. SystemColors.Co ntrolText
Me.DataGrid1.Lo cation = New System.Drawing. Point(16, 120)
Me.DataGrid1.Na me = "DataGrid1"
Me.DataGrid1.Si ze = New System.Drawing. Size(472, 208)
Me.DataGrid1.Ta bIndex = 0
'
'TextBox1
'
Me.TextBox1.Loc ation = New System.Drawing. Point(24, 56)
Me.TextBox1.Nam e = "TextBox1"
Me.TextBox1.Siz e = New System.Drawing. Size(48, 20)
Me.TextBox1.Tab Index = 1
Me.TextBox1.Tex t = "TextBox1"
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(24, 88)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 2
Me.Button1.Text = "Next"
'
'TextBox2
'
Me.TextBox2.Loc ation = New System.Drawing. Point(80, 56)
Me.TextBox2.Nam e = "TextBox2"
Me.TextBox2.Siz e = New System.Drawing. Size(112, 20)
Me.TextBox2.Tab Index = 3
Me.TextBox2.Tex t = "TextBox2"
'
'Button2
'
Me.Button2.Loca tion = New System.Drawing. Point(136, 88)
Me.Button2.Name = "Button2"
Me.Button2.TabI ndex = 4
Me.Button2.Text = "Add Child"
'
'Button3
'
Me.Button3.Loca tion = New System.Drawing. Point(240, 88)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing. Size(96, 23)
Me.Button3.TabI ndex = 5
Me.Button3.Text = "Delete Parent"
'
'Button4
'
Me.Button4.Loca tion = New System.Drawing. Point(376, 88)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing. Size(96, 23)
Me.Button4.TabI ndex = 6
Me.Button4.Text = "Show Changes"
'
'Button5
'
Me.Button5.Loca tion = New System.Drawing. Point(24, 16)
Me.Button5.Name = "Button5"
Me.Button5.TabI ndex = 7
Me.Button5.Text = "Load Data"
'
'CheckBox1
'
Me.CheckBox1.Ch ecked = True
Me.CheckBox1.Ch eckState = System.Windows. Forms.CheckStat e.Checked
Me.CheckBox1.Lo cation = New System.Drawing. Point(104, 16)
Me.CheckBox1.Na me = "CheckBox1"
Me.CheckBox1.Si ze = New System.Drawing. Size(64, 24)
Me.CheckBox1.Ta bIndex = 8
Me.CheckBox1.Te xt = "Async"
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(496, 334)
Me.Controls.Add (Me.CheckBox1)
Me.Controls.Add (Me.Button5)
Me.Controls.Add (Me.Button4)
Me.Controls.Add (Me.Button3)
Me.Controls.Add (Me.Button2)
Me.Controls.Add (Me.TextBox2)
Me.Controls.Add (Me.Button1)
Me.Controls.Add (Me.TextBox1)
Me.Controls.Add (Me.DataGrid1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGr id1, System.Componen tModel.ISupport Initialize).End Init()
Me.ResumeLayout (False)

End Sub

#End Region

Private Class DataAccess
Private Const SQL_CONNECTION_ STRING As String = _
"Data Source=localhos t;" & _
"Initial Catalog=Northwi nd;" & _
"Integrated Security=SSPI"

Public Event DataLoaded(ByVa l sender As Object, ByVal e As EventArgs)
Protected Overridable Sub OnDataLoaded(By Val e As EventArgs)
RaiseEvent DataLoaded(Me, e)
End Sub

Public Sub GetData(ByRef ds As DataSet)
ds = New DataSet
Dim da, da2 As SqlDataAdapter
Dim cnn As SqlConnection
Try
cnn = New SqlConnection(S QL_CONNECTION_S TRING)

da = New SqlDataAdapter( "SELECT * FROM Region", cnn)
da.Fill(ds, "Region")
da = New SqlDataAdapter( "SELECT * FROM Territories", cnn)
da.Fill(ds, "Territorie s")

ds.Relations.Ad d("Region_Terri tories", _
ds.Tables("Regi on").Columns("R egionID"), _
ds.Tables("Terr itories").Colum ns("RegionID") )

ds.DataSetName = "RegionTerritor ies"

OnDataLoaded(Ev entArgs.Empty)

Catch Exp As Exception
MessageBox.Show (Exp.Message)
End Try
End Sub

End Class

Private Delegate Sub GetDataArgsDele gate(ByVal e As EventArgs)

Private WithEvents Access As New DataAccess
Private myDataSet As DataSet
Private cmParent, cmChild As CurrencyManager

Private m_async As Boolean = True
Public Property LoadAsync() As Boolean
Get
Return m_async
End Get
Set(ByVal Value As Boolean)
m_async = Value
End Set
End Property

Private m_isDataLoaded As Boolean = False
Public Property IsDataLoaded() As Boolean
Get
Return m_isDataLoaded
End Get
Set(ByVal Value As Boolean)
m_isDataLoaded = Value
End Set
End Property

Private Sub Button5_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button5.Click
Me.Button5.Enab led = False
Me.BeginGetData ()
End Sub

Private Sub BeginGetData()
m_isDataLoaded = False
Me.DataGrid1.Da taSource = Nothing
Me.TextBox1.Dat aBindings.Clear ()
Me.TextBox2.Dat aBindings.Clear ()
Me.TextBox1.Tex t = ""
Me.TextBox2.Tex t = "Loading Data..."

If Me.LoadAsync Then
Dim t As New Threading.Threa d(AddressOf Me.GetData)
t.Name = Me.Name + "DataThread "
t.IsBackground = True
t.Start()
Else
Me.GetData()
End If
End Sub

Private Sub EndGetData(ByVa l e As EventArgs)
m_isDataLoaded = True

Me.DataGrid1.Da taSource = myDataSet
Me.DataGrid1.Da taMember = "Region.Region_ Territories"

Me.TextBox1.Dat aBindings.Add(" Text", myDataSet, "Region.RegionI D")
Me.TextBox2.Dat aBindings.Add(" Text", myDataSet,
"Region.RegionD escription")

cmParent = Me.BindingConte xt(myDataSet, "Region")
cmChild = Me.BindingConte xt(myDataSet, "Region.Region_ Territories")
Me.Button5.Enab led = True
End Sub

Public Sub GetData()
'Simulates a longer time.....
System.Threadin g.Thread.Sleep( 5000)
Access.GetData( myDataSet)
End Sub

Private Sub Access_DataLoad ed(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Access.DataLoad ed
If Me.InvokeRequir ed Then
'-- Marshall to the UI thread...
Dim dlg As New GetDataArgsDele gate(AddressOf EndGetData)
Dim args() As Object = {e}
Me.BeginInvoke( dlg, args)
Else
Me.EndGetData(E ventArgs.Empty)
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
If Me.IsDataLoaded Then
cmParent.Positi on += 1
End If
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
If Me.IsDataLoaded Then
cmChild.AddNew( )
End If
End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
If Me.IsDataLoaded Then
cmParent.Remove At(cmParent.Pos ition)
End If
End Sub

Public Overridable Sub ShowDiffData()
'-- View the diffgram in the web browser
Try
If Not (myDataSet Is Nothing) Then

Dim cFileName As String =
Environment.Get FolderPath(Envi ronment.Special Folder.LocalApp licationData) +
"\Diff"
Dim dsDiffgram As DataSet

If myDataSet.HasCh anges Then
dsDiffgram = myDataSet.GetCh anges()
dsDiffgram.Writ eXml(cFileName + myDataSet.DataS etName + ".xml",
XmlWriteMode.Di ffGram)
System.Diagnost ics.Process.Sta rt("file://" + cFileName +
myDataSet.DataS etName + ".xml")
Else
MessageBox.Show ("Please make changes first.", "Show Changes",
MessageBoxButto ns.OK, MessageBoxIcon. Information)
End If
End If
Catch exp As Exception
End Try
End Sub

Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
If Me.IsDataLoaded Then
Me.ShowDiffData ()
End If
End Sub

Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles CheckBox1.Check edChanged
Me.LoadAsync = Me.CheckBox1.Ch ecked
End Sub
End Class

"Doug Bell" <du*@bigpond.co m> wrote in message
news:e9******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
I have an application that has a "Data Access Class" and "User Interface
Class".

It is for receiving Purchase Order data from one system and pushing
processed transactions to another system.

The system generally works quite well.
Currently the User interface calls for a refresh of data every 15 minutes
(selectable) and the Data Access Class connects to the DB and retrieves
the
data structured to suit the application. During the retrieval it displays
messages informing the User of the various downloads. Each application has
its own Data Access Class. It takes between 30 seconds and 5 minutes to
refresh the data dependant on where the User is located

I have been asked to make the refresh transparent so that the User does
not
have to wait for the Data Access Layer to get its data as some site have a
very slow connections to the network.

I am not sure how to achieve this new requirement.
I thought that I could make the Data Access Class a separate application
that loads with the User interface and then periodically retrieves the
data
and saves it into a local database file (mdb ?) rather than into the
current
Data Set and then have the User Interface asynchronously connect to the
local database and update its records.

I would appreciate any oppinions.

Regards

Doug

Nov 21 '05 #2
Doug,

I absolute don't see from your message what you are doing. I think that an
newsgroup message is not able to show that. You can try it however than it
becomes probably so long that nobody reads it, so it has no sense to explain
it more in my opinion.

However you asked an opinion. I surely would not go the direction in
duplicating your data in an access database. I have seen a lot of people
trying that in these newsgroups. It is difficult managable and cost as well
probably a lot of time.

To give you my first idea, that was creating XML files dataset on the server
and than distribute those on that 15 minute base by instance with a
webservice. (Where you than would have to decide if you create on your
server the xmlfiles on a time base or on demand).

However that last is just an idea that I got reading your message and never
did.

I hope this helps somehow

Cor
Nov 21 '05 #3
Thanks Beth, I will have a look at that. I haven't done anything in
different threads before.
I wonder if I could get around locking access to the data by buffering it
into a secon data set, updating ds1 and then cloning ds1 to ds2 so that it
is only unavailable momentarily?

Thanjs

"Beth Massi [Architect MVP]" <bm****@comcast .net> wrote in message
news:eV******** ******@tk2msftn gp13.phx.gbl...
Hi Doug,

You can execute the loading of your data on a separate thread so that the
form is still responsive to the user, however, you need to be careful that
none of the UI elements work with that data before the data is retrieved.
Once the data is loaded, your data access class should raise an event that
you can handle so you can call the invoke method to marshal the call to the UI thread. Here's the basic idea (note- this example uses the SQL northwind database):

Public Class Form1
Inherits System.Windows. Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeCompo nent()

'Add any initialization after the InitializeCompo nent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Disp ose()
End If
End If
MyBase.Dispose( disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.Componen tModel.IContain er

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents DataGrid1 As System.Windows. Forms.DataGrid
Friend WithEvents TextBox1 As System.Windows. Forms.TextBox
Friend WithEvents Button1 As System.Windows. Forms.Button
Friend WithEvents TextBox2 As System.Windows. Forms.TextBox
Friend WithEvents Button2 As System.Windows. Forms.Button
Friend WithEvents Button3 As System.Windows. Forms.Button
Friend WithEvents Button4 As System.Windows. Forms.Button
Friend WithEvents Button5 As System.Windows. Forms.Button
Friend WithEvents CheckBox1 As System.Windows. Forms.CheckBox
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
Me.DataGrid1 = New System.Windows. Forms.DataGrid
Me.TextBox1 = New System.Windows. Forms.TextBox
Me.Button1 = New System.Windows. Forms.Button
Me.TextBox2 = New System.Windows. Forms.TextBox
Me.Button2 = New System.Windows. Forms.Button
Me.Button3 = New System.Windows. Forms.Button
Me.Button4 = New System.Windows. Forms.Button
Me.Button5 = New System.Windows. Forms.Button
Me.CheckBox1 = New System.Windows. Forms.CheckBox
CType(Me.DataGr id1, System.Componen tModel.ISupport Initialize).Beg inInit() Me.SuspendLayou t()
'
'DataGrid1
'
Me.DataGrid1.An chor = CType((((System .Windows.Forms. AnchorStyles.To p Or
System.Windows. Forms.AnchorSty les.Bottom) _
Or System.Windows. Forms.AnchorSty les.Left) _
Or System.Windows. Forms.AnchorSty les.Right),
System.Windows. Forms.AnchorSty les)
Me.DataGrid1.Da taMember = ""
Me.DataGrid1.He aderForeColor = System.Drawing. SystemColors.Co ntrolText
Me.DataGrid1.Lo cation = New System.Drawing. Point(16, 120)
Me.DataGrid1.Na me = "DataGrid1"
Me.DataGrid1.Si ze = New System.Drawing. Size(472, 208)
Me.DataGrid1.Ta bIndex = 0
'
'TextBox1
'
Me.TextBox1.Loc ation = New System.Drawing. Point(24, 56)
Me.TextBox1.Nam e = "TextBox1"
Me.TextBox1.Siz e = New System.Drawing. Size(48, 20)
Me.TextBox1.Tab Index = 1
Me.TextBox1.Tex t = "TextBox1"
'
'Button1
'
Me.Button1.Loca tion = New System.Drawing. Point(24, 88)
Me.Button1.Name = "Button1"
Me.Button1.TabI ndex = 2
Me.Button1.Text = "Next"
'
'TextBox2
'
Me.TextBox2.Loc ation = New System.Drawing. Point(80, 56)
Me.TextBox2.Nam e = "TextBox2"
Me.TextBox2.Siz e = New System.Drawing. Size(112, 20)
Me.TextBox2.Tab Index = 3
Me.TextBox2.Tex t = "TextBox2"
'
'Button2
'
Me.Button2.Loca tion = New System.Drawing. Point(136, 88)
Me.Button2.Name = "Button2"
Me.Button2.TabI ndex = 4
Me.Button2.Text = "Add Child"
'
'Button3
'
Me.Button3.Loca tion = New System.Drawing. Point(240, 88)
Me.Button3.Name = "Button3"
Me.Button3.Size = New System.Drawing. Size(96, 23)
Me.Button3.TabI ndex = 5
Me.Button3.Text = "Delete Parent"
'
'Button4
'
Me.Button4.Loca tion = New System.Drawing. Point(376, 88)
Me.Button4.Name = "Button4"
Me.Button4.Size = New System.Drawing. Size(96, 23)
Me.Button4.TabI ndex = 6
Me.Button4.Text = "Show Changes"
'
'Button5
'
Me.Button5.Loca tion = New System.Drawing. Point(24, 16)
Me.Button5.Name = "Button5"
Me.Button5.TabI ndex = 7
Me.Button5.Text = "Load Data"
'
'CheckBox1
'
Me.CheckBox1.Ch ecked = True
Me.CheckBox1.Ch eckState = System.Windows. Forms.CheckStat e.Checked
Me.CheckBox1.Lo cation = New System.Drawing. Point(104, 16)
Me.CheckBox1.Na me = "CheckBox1"
Me.CheckBox1.Si ze = New System.Drawing. Size(64, 24)
Me.CheckBox1.Ta bIndex = 8
Me.CheckBox1.Te xt = "Async"
'
'Form1
'
Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
Me.ClientSize = New System.Drawing. Size(496, 334)
Me.Controls.Add (Me.CheckBox1)
Me.Controls.Add (Me.Button5)
Me.Controls.Add (Me.Button4)
Me.Controls.Add (Me.Button3)
Me.Controls.Add (Me.Button2)
Me.Controls.Add (Me.TextBox2)
Me.Controls.Add (Me.Button1)
Me.Controls.Add (Me.TextBox1)
Me.Controls.Add (Me.DataGrid1)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.DataGr id1, System.Componen tModel.ISupport Initialize).End Init()
Me.ResumeLayout (False)

End Sub

#End Region

Private Class DataAccess
Private Const SQL_CONNECTION_ STRING As String = _
"Data Source=localhos t;" & _
"Initial Catalog=Northwi nd;" & _
"Integrated Security=SSPI"

Public Event DataLoaded(ByVa l sender As Object, ByVal e As EventArgs)
Protected Overridable Sub OnDataLoaded(By Val e As EventArgs)
RaiseEvent DataLoaded(Me, e)
End Sub

Public Sub GetData(ByRef ds As DataSet)
ds = New DataSet
Dim da, da2 As SqlDataAdapter
Dim cnn As SqlConnection
Try
cnn = New SqlConnection(S QL_CONNECTION_S TRING)

da = New SqlDataAdapter( "SELECT * FROM Region", cnn)
da.Fill(ds, "Region")
da = New SqlDataAdapter( "SELECT * FROM Territories", cnn)
da.Fill(ds, "Territorie s")

ds.Relations.Ad d("Region_Terri tories", _
ds.Tables("Regi on").Columns("R egionID"), _
ds.Tables("Terr itories").Colum ns("RegionID") )

ds.DataSetName = "RegionTerritor ies"

OnDataLoaded(Ev entArgs.Empty)

Catch Exp As Exception
MessageBox.Show (Exp.Message)
End Try
End Sub

End Class

Private Delegate Sub GetDataArgsDele gate(ByVal e As EventArgs)

Private WithEvents Access As New DataAccess
Private myDataSet As DataSet
Private cmParent, cmChild As CurrencyManager

Private m_async As Boolean = True
Public Property LoadAsync() As Boolean
Get
Return m_async
End Get
Set(ByVal Value As Boolean)
m_async = Value
End Set
End Property

Private m_isDataLoaded As Boolean = False
Public Property IsDataLoaded() As Boolean
Get
Return m_isDataLoaded
End Get
Set(ByVal Value As Boolean)
m_isDataLoaded = Value
End Set
End Property

Private Sub Button5_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button5.Click
Me.Button5.Enab led = False
Me.BeginGetData ()
End Sub

Private Sub BeginGetData()
m_isDataLoaded = False
Me.DataGrid1.Da taSource = Nothing
Me.TextBox1.Dat aBindings.Clear ()
Me.TextBox2.Dat aBindings.Clear ()
Me.TextBox1.Tex t = ""
Me.TextBox2.Tex t = "Loading Data..."

If Me.LoadAsync Then
Dim t As New Threading.Threa d(AddressOf Me.GetData)
t.Name = Me.Name + "DataThread "
t.IsBackground = True
t.Start()
Else
Me.GetData()
End If
End Sub

Private Sub EndGetData(ByVa l e As EventArgs)
m_isDataLoaded = True

Me.DataGrid1.Da taSource = myDataSet
Me.DataGrid1.Da taMember = "Region.Region_ Territories"

Me.TextBox1.Dat aBindings.Add(" Text", myDataSet, "Region.RegionI D")
Me.TextBox2.Dat aBindings.Add(" Text", myDataSet,
"Region.RegionD escription")

cmParent = Me.BindingConte xt(myDataSet, "Region")
cmChild = Me.BindingConte xt(myDataSet, "Region.Region_ Territories")
Me.Button5.Enab led = True
End Sub

Public Sub GetData()
'Simulates a longer time.....
System.Threadin g.Thread.Sleep( 5000)
Access.GetData( myDataSet)
End Sub

Private Sub Access_DataLoad ed(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Access.DataLoad ed
If Me.InvokeRequir ed Then
'-- Marshall to the UI thread...
Dim dlg As New GetDataArgsDele gate(AddressOf EndGetData)
Dim args() As Object = {e}
Me.BeginInvoke( dlg, args)
Else
Me.EndGetData(E ventArgs.Empty)
End If
End Sub

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
If Me.IsDataLoaded Then
cmParent.Positi on += 1
End If
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
If Me.IsDataLoaded Then
cmChild.AddNew( )
End If
End Sub

Private Sub Button3_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button3.Click
If Me.IsDataLoaded Then
cmParent.Remove At(cmParent.Pos ition)
End If
End Sub

Public Overridable Sub ShowDiffData()
'-- View the diffgram in the web browser
Try
If Not (myDataSet Is Nothing) Then

Dim cFileName As String =
Environment.Get FolderPath(Envi ronment.Special Folder.LocalApp licationData) + "\Diff"
Dim dsDiffgram As DataSet

If myDataSet.HasCh anges Then
dsDiffgram = myDataSet.GetCh anges()
dsDiffgram.Writ eXml(cFileName + myDataSet.DataS etName + ".xml",
XmlWriteMode.Di ffGram)
System.Diagnost ics.Process.Sta rt("file://" + cFileName +
myDataSet.DataS etName + ".xml")
Else
MessageBox.Show ("Please make changes first.", "Show Changes",
MessageBoxButto ns.OK, MessageBoxIcon. Information)
End If
End If
Catch exp As Exception
End Try
End Sub

Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
If Me.IsDataLoaded Then
Me.ShowDiffData ()
End If
End Sub

Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles CheckBox1.Check edChanged
Me.LoadAsync = Me.CheckBox1.Ch ecked
End Sub
End Class

"Doug Bell" <du*@bigpond.co m> wrote in message
news:e9******** ******@TK2MSFTN GP12.phx.gbl...
Hi,
I have an application that has a "Data Access Class" and "User Interface
Class".

It is for receiving Purchase Order data from one system and pushing
processed transactions to another system.

The system generally works quite well.
Currently the User interface calls for a refresh of data every 15 minutes (selectable) and the Data Access Class connects to the DB and retrieves
the
data structured to suit the application. During the retrieval it displays messages informing the User of the various downloads. Each application has its own Data Access Class. It takes between 30 seconds and 5 minutes to
refresh the data dependant on where the User is located

I have been asked to make the refresh transparent so that the User does
not
have to wait for the Data Access Layer to get its data as some site have a very slow connections to the network.

I am not sure how to achieve this new requirement.
I thought that I could make the Data Access Class a separate application
that loads with the User interface and then periodically retrieves the
data
and saves it into a local database file (mdb ?) rather than into the
current
Data Set and then have the User Interface asynchronously connect to the
local database and update its records.

I would appreciate any oppinions.

Regards

Doug


Nov 21 '05 #4
Thanks Cor,
I understand it is difficult to see what I am trying to achieve.

I would rather keep it as a dataset in memory. And possibly I can do
something like using a different thread as Beth has suggested.

I did not mention but the data has to be available even when the AS400
Server is busy doing End Of Day and End Of Month stuff.
That is currently handled by writing the local Data Set to an XML when ever
it is refreshed but I think generating and distributing XML from the AS400
is out of the question.

Doug

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:ut******** ******@TK2MSFTN GP14.phx.gbl...
Doug,

I absolute don't see from your message what you are doing. I think that an
newsgroup message is not able to show that. You can try it however than it
becomes probably so long that nobody reads it, so it has no sense to explain it more in my opinion.

However you asked an opinion. I surely would not go the direction in
duplicating your data in an access database. I have seen a lot of people
trying that in these newsgroups. It is difficult managable and cost as well probably a lot of time.

To give you my first idea, that was creating XML files dataset on the server and than distribute those on that 15 minute base by instance with a
webservice. (Where you than would have to decide if you create on your
server the xmlfiles on a time base or on demand).

However that last is just an idea that I got reading your message and never did.

I hope this helps somehow

Cor

Nov 21 '05 #5
Doug,
Thanks Cor,
I understand it is difficult to see what I am trying to achieve.

I would rather keep it as a dataset in memory.
This does not change when you use the XML file as Intermidiate, only there
is not needed any action from the server, and probably will that save time.
(You can even think on zipping and dezipping it). (See my part about the
AS400 later).
And possibly I can do something like using a different thread as Beth has
suggested.
What do you than achieve with that. Or don't you have updates? That makes it
even more to try the solution I told.

I did not mention but the data has to be available even when the AS400
Server is busy doing End Of Day and End Of Month stuff.
That is currently handled by writing the local Data Set to an XML when
ever
it is refreshed but I think generating and distributing XML from the AS400
is out of the question.

Than I would probalby try directly to integrate an extra server in my
domain, that only gets that data, set it on a XMLfile dataset and is the
server for the clients to get that dataset.

However as I said I never tried.

Cor
Nov 21 '05 #6
Dough,

I have looked better at the solution from Beth, there is nothing that
conflicts with my idea of a solution. You can integrate both.

Cor
Nov 21 '05 #7
doh,

I have looked better at the solution from Beth, there is nothing that
conflicts with my idea of a solution. You can integrate both.
Assuming again that there are no updates needed. Cor

Nov 21 '05 #8
Cor,
There are no updates.
Processed transactions go through a different system.

But I don't see how I can get AS400 to generate (and optionally zip) an XML
file?

I can see benefits if I could.

Doug

"Cor Ligthert" <no************ @planet.nl> wrote in message
news:ul******** ******@TK2MSFTN GP12.phx.gbl...
doh,

I have looked better at the solution from Beth, there is nothing that
conflicts with my idea of a solution. You can integrate both.

Assuming again that there are no updates needed.
Cor


Nov 21 '05 #9
Doug,

But I don't see how I can get AS400 to generate (and optionally zip) an
XML
file?

Only with that extra server as I wrote.

That server collects the data from the AS400 in the same way as now the
clients do.

When ready write a zipped serialized dataset as a blob (bytearray).

With a Webservice you make it the client possible to get that blob.

The client do on seperated times (what can be even in a extra thread) the
collections of that blob using that webservice, unzip it and read (or
deserialize it) it in the proper place when it is arrived.

However again just an idea with what I see directly not much problems to
realise when you have somewhere a server which you can use for that. (It
needs IIS and ASPNET).

Cor
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3291
by: J. Baute | last post by:
I'm caching data in the Application object to speed up certain pages on a website The main reason is that the retrieval of this data takes quite a while (a few seconds) and fetching the same data from the "cache" hardly takes any time A basic pattern used to get the data from disk, or from cache is this data = getDataFromCache("mydata" if data = "" the data = getDataFromDisk( storeDataInCache(data, "mydata" end i
0
4811
by: Redd | last post by:
The following is a technical report on a data modeling project that was recently assigned to me by my professor. I post it so that anyone else who is studying databases and data modeling can have an example to go by with their study of databases. I was assinged to come up with a data model, but I choose the Autoparts sales and inventory management schema. It you would like the SQL code to generate the schema or if you would like the ERWin...
7
2239
by: Will | last post by:
On the subject of Data Warehouses, Data Cubes & OLAP…. I would like to speak frankly about Data Warehouses, Data Cubes and OLAP (on-line analytical processing). Has it dawned on anyone else that these buzz words were created by some geek who decided to take a stab at marketing? Knowing that to the backwoods manager who knows little of technology that new innovative names for old concepts would help to sale their products. I mean...
11
3198
by: Konrad Den Ende | last post by:
I have a function returning a string but the problem is that the color of it is blue which suits me well for some pages but not for others. Is it possible to "feel" what the color of the background in the current document is and set the color of the output accordingly? The background will be an image, in most cases. -- Kindly Konrad
3
1741
by: GP | last post by:
We are connecting to sql server database in the webservices & retrieve the data as dataset from the webservices and load it to the aspx pages ,But we find loading of the aspx pages takes longer time than the pages that retrieve data directly using cs files.Is it good practise to use the data retrieval in web services. Can some help me in this issue. Thanks GP
0
4426
by: JosAH | last post by:
Greetings, Introduction At the end of the last Compiler article part I stated that I wanted to write about text processing. I had no idea what exactly to talk about; until my wife commanded me to "clean up that mess you never use anyway and please dump the rest of it in the attic or simply throw that junk away". I want to make a statement here:
0
1553
by: twoSeven | last post by:
hi, Here is what i want to do. I am making a file and folder browser similar to Windows Explorer with a treeview and listview.. In that, i get icons and thumbnails of a particular file/folder from a function(getMyIcon()) which interacts with shell to get icons and updates the two imagelists( for small and large icons).this in turn is used to update a listview to show the file/folder name and the icons. The problem is the UI becomes...
0
3510
by: JosAH | last post by:
Greetings, welcome back; above we discussed the peripherals of the Library class: loading and saving such an instantiation of it, the BookMark interface and then some. This part of the article discusses the internals of the Library class a bit more. Sections again A previous article part showed how Sections work, i.e. a group Section refers to book Sections, a book Section refers to chapter Sections and the latter refer
5
1919
by: John | last post by:
Hi I have a master data set. I need to populate a copy of this data set in the background (via background thread?) and once filled to replace master data set with the newly filled dataset. Is there a code example of this that can see? Thanks Regards
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.