LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-27-2005, 09:33 AM   #1
mrobertson
Member
 
Registered: May 2005
Posts: 275

Rep: Reputation: 30
Appending data to a datagrid


I am currently working on an application where I will need to progressively build a data grid. I have a text file that looks like this:

1006, 32.56, .1348, .0466
1007, 33.12, .1234, .9876

I am going to need to read each line one at a time. One the first time around 1006 needs to go into "its text box" and so on. From there I need to query based on line 1's data and print to datagrid. Then I need to read line two and clear 1006 from the text box and put in 1007 and so on and then query for this set of data and append it to the data grid at the end of the data from the first line.

Can anybody help me as to how this would be done?
 
Old 07-28-2005, 07:37 AM   #2
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
appending data to a data grid VB.net

I am working on an application in which I am going to need to append data to a data grid. Basically, I am going to have a loop that will read a text box, query for info in text box, print to data grid, change info in text box, query and print again and so on. I will need the first set of data displayed, then the next set appended to the previous set at the end, etc, etc. Can anyone help me with how to do this?
 
Old 07-28-2005, 08:11 AM   #3
ewaltd
LQ Newbie
 
Registered: Jul 2005
Distribution: SuSE 9.3 Pro and FC3
Posts: 17

Rep: Reputation: 0
Don't know that this has anything to do with linux dev but....


If you are using a dataset...

Create a dataview on the dataset.
Bind the dataview ( not the dataset ) to the grid.

Then when you want to add data to the grid...

Grab the dataview back from the grid's datasource.
Add the data to the dataview.
Re-bind the dataview to the grid.

If you are using a custom object ( i.e. collection )...

Bind the collection to the grid

Then when you want to add data to the grid....

Grab the collection back from the grid's datasource
Add the new item to the collection.
Re-bind the colleciton to the grid.
 
Old 07-28-2005, 08:15 AM   #4
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
would you be able to give me some coding examples of how to do this. I have never dealt with a data view before nor heard of it. Some source code would be a great help.
 
Old 07-28-2005, 08:16 AM   #5
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I am coding in vb.net not a linux language
 
Old 07-28-2005, 08:52 AM   #6
ewaltd
LQ Newbie
 
Registered: Jul 2005
Distribution: SuSE 9.3 Pro and FC3
Posts: 17

Rep: Reputation: 0
There are tons of examples on datagrids, datasets, and dataviews in MSDN and on the web.

Doing a google search for any/all of those things will bring you more hits than you can read.
 
Old 07-28-2005, 08:57 AM   #7
mrobertson
Member
 
Registered: May 2005
Posts: 275

Original Poster
Rep: Reputation: 30
I tried something like this and got an Ora - 01722: Invalid Name the second time through the loop on the bolded line.

Code:
Private Sub butReadFromtextfile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butReadFromtextfile.Click
        Try
            Dim mLine As String
            Dim oFile As System.IO.File
            Dim oRead As System.IO.StreamReader
            oRead = oFile.OpenText("C:\Documents and Settings\alogue\Desktop\Coil PDI\PDI.txt")

            While oRead.Peek <> -1
                mLine = oRead.ReadLine()
                'Get and split line details 
                Dim mControlInfo(4) As String                 'Sets up the 3 elements on the current line 
                mControlInfo = mLine.Split(",")               'Tab between the quotes - i used commas, much easier 
                txtgradecode.AppendText(mControlInfo(0))
                txtwidth.AppendText(mControlInfo(1))
                txthbgauge.AppendText(mControlInfo(2))
                txttargetgauge.AppendText(mControlInfo(3))
                Dim coilpdi As String
                Dim CoilPDIRowCount As Integer
                Dim PDIDataset As New DataSet

                Dim myConnection As New OracleConnection("Data Source=DUF_TCM; User ID=PCC;Password=DUFERCO")

                myConnection.Open()
                'Queries for the rolls that match the specified pdi
                coilpdi = "Select * from tcm_planned_coil where process_status = 'PLN' and grade_code ='" + txtgradecode.Text + "' and width = '" + txtwidth.Text + "' and hot_band_gauge='" + txthbgauge.Text + "' and target_gauge='" + txttargetgauge.Text + "' order by schedule_number, sequence_number"

                Dim PDICommand As New OracleCommand(coilpdi, myConnection)
                Dim PDIAdapter As New OracleDataAdapter(PDICommand)

                'clears the dataset 
                PDIDataset.Clear()

                'using the command object, open a data adapter
                PDIAdapter.SelectCommand = PDICommand

                'Fills the data adapter with the dataset
                PDIAdapter.Fill(PDIDataset, "Table2")

                With Me.dgQueryResults
                    .DataSource = PDIDataset 'display the data in the datagrid
                    .NavigateTo(0, -1) 'expand the datagrid one level
                    .NavigateTo(0, "Table2") 'expand the datagrid down to the child level to show query results
                    .ParentRowsVisible = False
                    .AllowSorting = True
                    .AllowNavigation = True
                    .AllowDrop = False
                    .ColumnHeadersVisible = True
                    .PreferredColumnWidth = 300 'Set in pixels
                    .TabStop = False
                    .Enabled = True
                    .Visible = True
                    .ReadOnly = True
                    .AlternatingBackColor = System.Drawing.Color.Bisque
                End With

                CoilPDIRowCount = PDIDataset.Tables("Table2").Rows.Count

            End While

            oRead.Close()
            AddCellFormattingColumnStyles(Me.dgQueryResults, New FormatCellEventHandler(AddressOf FormatGridCells)) ' This is a private Sub within this class.
            myConnection.Close()


        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information)
        Finally

        End Try
    End Sub
Does this look like it will append data or just write over the first set? I have google appending data to a datagrid and data views alot and havent found any useful ino yet.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Painting the row of a data grid a color in VB.net mrobertson Programming 1 07-30-2005 04:22 PM
vb.net error when trying to format data grid mrobertson Programming 23 07-29-2005 11:52 AM
appending data to a data grid mrobertson Programming 1 07-28-2005 10:07 PM
Home Office Biotech Data Mining - Data Collection Adler Linux - General 20 11-03-2004 04:17 AM
Burn Data DVD... Read Data in Linux and Windows SaintStrive Linux - Newbie 3 09-18-2004 05:04 PM


All times are GMT -5. The time now is 11:35 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration