|
You don't. A DataView has no rows of its own. A View is just that, a different view of rows in a DataTable.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
OK, I see. What if I let the user sort a datagrid that is bound to a datatable... how do I get the sorted rows back into the datatable?
thanks again
|
|
|
|
|
You don't. SQL and Access doesn't sort the data in the tables. Sorting only applies to the view of the data, not the table behind it.
When you bind a DataGrid to a DataTable, you're actually seeing the DefaultDataView of that DataTable, not the DataTable itself.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
OK, but what if I want to allow the user to save the current datagridview as a datatable? How do I get the updated rows of the current view from the datagrid into a new table for saving?
thanks
|
|
|
|
|
It's already a DataTable. The DataGridView is showing you a VIEW of that data, not the data itself.
What are you trying to do with all this?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I want to save the edited view as a datatable to xml.
For instance:
1. Read table from XML
2. Put table into datagridview
3. User deletes rows and/or sorts the datagridview
4. User now XMLsaves the edited datagridview as the original datatable
|
|
|
|
|
Since none of these data methods actually saves, or cares, about the order of records, what's the point? The order of the records, as displayed, is controlled by the presentation layer, not the data layer...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Right, but I want to persist the modified datatable across sessions in the saved .xml -- or for import to another program.
|
|
|
|
|
You can get a new DataTable made with the current view by calling the .ToTable() method on the view that your DataGridView is bound to. Something like:
Dim newTable As DataTable = myOldTable.DefaultView.ToTable()
You can then save the new table as an XML file using any method you want.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
excellent! Thanks for your patience...
|
|
|
|
|
Hello,
I am looking for a SIMPLE way to play a music file, preferibly without windows media play; I would like to be able to play mp3 and wma files.
Thanks
Al968
Avast Antivirus-http://www.avast.com
|
|
|
|
|
haven't tried any of the links but
http://www.vbcodesource.com/controlNet.html
|
|
|
|
|
Thanks for the responce, I tested those but they only seem to work for vb6
Thanks Anyway
Al968
Avast Antivirus-<url>http://www.avast.com<url>
|
|
|
|
|
you can still use them with interopt?
|
|
|
|
|
Impossible. There is no 'simple' way to decode an mp3, the simplest is to let WMP do it for you.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi!
I open a text file but before a create a loop to iterate throug alll records I want to know how many lines (records) in the text file.
fileReader = My.Computer.FileSystem.OpenTextFileReader(aspath + "\dictioneries\read.txt")
Is it possible without performing a loop? If it is, what is the right statement to use?
Thank You.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
JUNEYT wrote:
Is it possible without performing a loop? If it is, what is the right statement to use?
Not that I know of. Why wouldn't you want to use a loop?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Something will perform a loop even if it isnt you.
While fileReader.Peek <> -1
End While That is the loop I prefer to use for file reading.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
There's no way to do it without reading the entire file, preferrably in a loop. The FileStream classes don't know what constitutes a record, so there's no way for it to know how many there are.
There is a way to calculate it though, but only works in limited cases where every record in the file is exactly the same length. Get the size of the file in bytes divide that by the length of a single record, including the termination characters, if any. That'll give you the number of records in the file, but only if each and every record is exactly the same length.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I am trying to write an RSS Reader, but I'm having some problems. I can get the data from each xml element, but I'm not sure how to organize them via element type (i.e. Title, Link and Description). I have searched everywhere, but all I can find are old examples that have hundreds of errors. How should I go about sorting the data? Is there some kind of trick in .Net 2.0?
The code I am using to read the data is:
Dim reader As New System.Xml.XmlTextReader("c:\feed.xml")
Dim contents As String = ""
While reader.Read()
reader.MoveToElement()
If reader.NodeType = Xml.XmlNodeType.Text Then
contents &= reader.Value & ControlChars.NewLine
MsgBox(contents)
End If
End While
Also, I have seen many examples use DataSets , is there any need for this? Thanks!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
I know that you can treat an XML stream as a dataset and step through it but you are probably looking for something along the lines of what you have or XPath.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that." - Tommy Boy "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Thanks for the reply. How would I arrange the data via a Dataset then?
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Hopefully this site[^] will help.
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Hi All,
I'm working with VB.Net 2003, I want to Get, Put, Delete the files in UNIX server via .Net programming.
I try to connect UNIX server using FTP its connected. then i'm trying to get the files its raising Error, I'm using NLST command,
the error is '500 NLST command not understood'
can any one help me out.
Thanks in Advance,
Ashok
|
|
|
|
|
It sounds like your FTP server on the UNIX box doesn't understand the NLST command. You might want to connect to it using a normal FTP clinet and try typing HELP to see what it understands.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|