Jump to content
Xtreme .Net Talk

mattsrebatespam

Members
  • Posts

    10
  • Joined

  • Last visited

Everything posted by mattsrebatespam

  1. unfortunately it was not by me. Here is what some of it would look like: <TABLENAME> <FIELD1>123</FIELD1> <FIELD2>123</FIELD2> <FIELD3>123</FIELD3> </TABLENAME> <TABLENAME> <FIELD1>123</FIELD1> <FIELD2>123</FIELD2> </TABLENAME> <TABLENAME> <FIELD1>123</FIELD1> <FIELD2>123</FIELD2> <FIELD3>123</FIELD3> <FIELD4>123</FIELD4> </TABLENAME> My database table has all 4 fields defined in it. The xml file will load as long as there are the correct number of fields present in the file. It is horrid XML but it is what I have to work with :(
  2. almost there... I figured out how to update from the XML file but have a few issues. Here is the code I am using: Dim MyDataSet As New DataSet MyDataSet.ReadXml("XMLFile.xml") Dim MyOleDbDataAdapter As New OleDbDataAdapter("SELECT * FROM MyTable", OleDbConnection) Dim MyOleDbCommandBuilder As New OleDb.OleDbCommandBuilder(MyOleDbDataAdapter) MyOleDbDataAdapter.Update(DemographicDataSet, "MyTable") I am having some issues with fields that are not present in every XML entry though. I have some fields in the MyTable database table that are not in every entry, they are in some though. I am getting errors from the program complaining about not finding the DataColumn in the DataTable for the SourceColumn. The fields in the database are not required. Any ideas?
  3. I have an XML file that I would like to write to a database. I know how to load the XML file to a dataset by using the DataSet.ReadXml command but I do not know how to write the resulting dataset to the database. Any ideas? I am using an MS Access database.
  4. Is it just not possible? The only other thing I can think of to do is create a database file and write all the entries to it and then query the results back to the program. That seems like an awful way to do it though.
  5. I am trying to summarize an existing datatable but have so far been unable to do so. I have a dataset called Results that I need to have displayed in two ways: all the details, and a summary. The Results datatable has 3 columns; Filter, Expression, Value. I want to be able to display the Expression and Value in the DetailDataGrid where the Filter is equal to the value in the FilterComboBox. Currently the DetailDataGrid is being populated as it should be. I also want to be able to summarize the Results table in the SummaryDataGrid. I want to find out how many records there are for each Expression having the Filter equal to the value in the FilterComboBox. This data is not coming out of a database, else I would make another call to the database with the query SELECT [Expression], Count([Expression]) FROM TABLE HAVING [Filter] = "Filter" GROUP BY [Expression]. I have tried to compute and select methods of the dataset but have had no luck so far. Is what I am trying to do possible? Here is the code I am using: Dim ResultDataSet As New DataSet ResultDataSet.Tables.Add(Results) ResultDataSet.Tables("Results").DefaultView.RowFilter = "[Filter] = '" & FilterComboBox.Text & "'" DetailDataGrid.DataSource = ResultDataSet.Tables("Results").DefaultView SummaryDataGrid.DataSource = ResultDataSet.Tables("Results").Compute("Count([Expression])", "[Filter] = '" & FilterComboBox.Text & "'") Any ideas or suggestions?
  6. Thanks for the advice. I knew about garbage collection but did not know how to use it. In my larger datasets I am doing 10 million+ searches (at about 10-15 thousand per second). It is just taking to long and I knew that there was a better way to manage the resources. I will try out your suggestions and see if it helps, thanks again!
  7. Multithreading out of control now I took your advice and made it dynamic. I created a thread to control the worker threads. The controller thread (ThreadController) only purpose is to spawn worker threads (ThreadWorker). The problem I am encountering now is that the number of threads is out of control. I know why (because of the loop in my code) but can't think of a way to make it behave. I also need to put a synlock in the code but I did not know how to do it. Any advice is greatly appreciated. Here is the code that is giving me the trouble: Public ThreadController As Thread Dim i As Integer = 1 Dim j As Integer = 20000 Private Sub StartButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartButton.Click ListBox.Items.Clear() StartButton.Enabled = False StopButton.Enabled = True PauseResumeButton.Enabled = True ThreadController = New Thread(AddressOf Me.ControlThreads) ThreadController.Start() End Sub Private Sub ControlThreads() Do While i < j For k As Integer = 1 To ThreadCountNumericUpDown.Value AddThread() Next Loop If i = j Then StartButton.Enabled = True StopButton.Enabled = False PauseResumeButton.Enabled = False End If End Sub Private Sub AddThread() Dim ThreadWorker As Thread = New Thread(AddressOf Me.BackgroundProcess) ThreadWorker.IsBackground = True ThreadWorker.Start() End Sub Private Sub BackgroundProcess() ListBox.Items.Add(i) i += 1 End Sub Private Sub PauseResumeButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PauseResumeButton.Click StartButton.Enabled = False StopButton.Enabled = True PauseResumeButton.Enabled = True If ThreadController.ThreadState = 64 Then ThreadController.Resume() Else ThreadController.Suspend() End If End Sub Private Sub StopButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StopButton.Click StartButton.Enabled = True StopButton.Enabled = False PauseResumeButton.Enabled = False If ThreadController.ThreadState = 64 Then ThreadController.Resume() End If ThreadController.Abort() ThreadController.Join() End Sub Private Sub ExitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitButton.Click Me.Close() End Sub MultiThreadtest.zip
  8. I am trying to get multithreading working for a project. I have created a test app so I can figure out the multithreading without having to worry about other issues. I have an arraylist that contains the numbers 1-100. I want to square those numbers and add them to a listbox. The problem I am having is that it runs though each thread one time and then it dies. I get errors about the thread unable to restart. I tried putting suspend and interrupt command in the background process but nothing helped so far. Any ideas? Here is the code I am using: Public ThreadControl1 As Thread = New Thread(AddressOf Me.BackgroundProcess) Public ThreadControl2 As Thread = New Thread(AddressOf Me.BackgroundProcess) Public ThreadControl3 As Thread = New Thread(AddressOf Me.BackgroundProcess) Public ThreadControl4 As Thread = New Thread(AddressOf Me.BackgroundProcess) Public SquareArrayList As New ArrayList Public i As Integer Private Sub BackgroundProcess() listbox1.Items.Add(SquareArrayList.Item(i) & " " & SquareArrayList.Item(i) * SquareArrayList.Item(i)) i += 1 End Sub Private Sub StartClick(sender As System.Object, e As System.EventArgs) Do While i < SquareArrayList.Count ThreadControl1.Start() ThreadControl2.Start() ThreadControl3.Start() ThreadControl4.Start() Loop End Sub
  9. Another thing I would like to add is that if I comment out the If.. Then part of the code where the match is performed (leaving the declaration of the regex object only) the memory usage is still high.
  10. I am trying to search through a bunch of text files (~25K-50K files) using regular expressions. I have a FileContentsArray array that contains each line of the file. I also have a SearchExpression array that has usually < 10 regular expressions. The code is working, but the memory usage is enormous. The program ties up all the system resources and takes forever to finish. I have managed to isolate the huge memory usage to the second line where I declare the Regexp. Is there any way to not declare it as a new object or to purge the object each time? I have tried to set Regexp = nothing but the memory used remains the same. Any help is greatly appreciated. For j = 0 To FileContentsArray.Count - 1 Dim Regexp As Regex = New Regex(SearchExpression.Item(k)) If Regexp.Match(FileContentsArray.Item(j)).Success Then 'add the match to a dataset End IfNext
×
×
  • Create New...