Hi,
I created a form and setup a Split Container - the left pane being a Tree View (with some top level nodes being topics: Memory, Operating System, Hard Drives, etc). The right pane contains a listbox.
Is it possible to use a dataset (with no DB connection) to hold all my information in memory Then I'd like to be able to query the dataset to fill the listbox with the info I need when a user click on a node in the left pane.
I've tried it, but I'm having some problems understanding how to do the dataset. If I create the dataset in design mode, I can create a table and add columns. But I seem to have problems accessing it from my code to add rows.
Here's what I've done...
I went to "Project" and then "Add New Item", selected DataSet and added a DataSet called BPIDataSet.xsd. I then added a DataTable from the Toolbox called BPI_DT to the DataSet. Then I added three columns: TopLevel, Topic, & Data. I made Topic the Primary Key.
I went back to my form and dragged over DataSet from the toolbox to the form. I left it as Typed dataset and with my BPIDataSet in the Name box (which it shows under my form as BPIDataSet1).
Here's an example of one record that will get created when a button is clicked:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.ClickDim anyRow As DataRow = BPIDataSet.BPI_DT.NewRow
anyRow.TopLevel =
"System Information"anyRow.Topic =
"OS Name"anyRow.Data =
My.Computer.Info.OSFullNameBPIDataSet.BPI_DT.Rows.Add(anyRow)
End Sub
However, under "BPIDataSet.BPI_DT" for both the Dim statement and the row addition line, I get the squiggly line telling me:
"reference to a non-shared member requires an object reference"
and under the anyRow statements I get the nice squiggly line telling me:
'TopLevel' is not a member of 'System.Data.DataRow'
and the same for Topic and Data.
I know this is something stupid, but can someone give me a hand and let me know if I'm at least headed in the right direction
Thank you very much for your help!!!!
-- Jim

Dataset Question
JRHudnutt
Matt Wyckhouse
hi,
yes you can do that
Private Sub mnuFile_ExportDataBase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFile_ExportDataBase.Click 'show dialog for user to select where s/he want to save the xml file Dim MySaveDialog As New SaveFileDialogMySaveDialog.Filter =
"DataBase |*.XML"MySaveDialog.Title =
"Save File" Dim result As DialogResult = MySaveDialog.ShowDialog() 'make sure that user hit okbutton and the dataset is not empty If Not result = Windows.Forms.DialogResult.Cancel AndAlso MainDataSet.Tables(0).Rows.Count = 0 Then
Try 'if the file exist allready delete it to replace it with new one If My.Computer.FileSystem.FileExists(MySaveDialog.FileName) = True Then My.Computer.FileSystem.DeleteFile(MySaveDialog.FileName) End If 'write the xml fileMainDataSet.WriteXml(MySaveDialog.FileName)
Catch ex As Exception 'throw a message if something wrong happendMessageBox.Show(
"A Problem occured during saved" & vbNewLine & ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If End Subhope this will help
fbalas
hi,
i was trying to make something like your question and i got this
Public
Class Form1 'Creat a dataset Dim BPI_Dataset As New DataSet 'creating a table Dim MyTable As New DataTable("BPI_Table") 'creat binding source Dim MyBindingSource As New BindingSource
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'set the colums for the tableMyTable.Columns.Add(
"ID", GetType(Integer))MyTable.Columns.Add(
"TopLevel", GetType(String))MyTable.Columns.Add(
"Topic", GetType(String))MyTable.Columns.Add(
"Data", GetType(String))MyTable.Columns(
"ID").Unique = TrueMyTable.Columns(
"Topic").Unique = TrueMyTable.PrimaryKey =
New DataColumn() {MyTable.Columns("Topic")} With MyTable.Columns("ID").AutoIncrement =
True.AutoIncrementSeed = 1
End With
'add table to datasetBPI_Dataset.Tables.Add(MyTable)
'bindingsourceMyBindingSource.DataSource = BPI_Dataset
MyBindingSource.DataMember =
"BPI_table" 'bind the data to your listbox Me.ListBox1.DataSource = MyBindingSource Me.ListBox1.DisplayMember = "Data" 'Add data to table Dim anyRow As DataRowanyRow = BPI_Dataset.Tables(
"BPI_Table").NewRowanyRow(
"TopLevel") = "System Information"anyRow(
"Topic") = "OS Name"anyRow(
"Data") = My.Computer.Info.OSFullNameBPI_Dataset.Tables(
"BPI_Table").Rows.Add(anyRow) 'second record Dim SecondRow As DataRowSecondRow = BPI_Dataset.Tables(
"BPI_Table").NewRowSecondRow(
"TopLevel") = "System Version"SecondRow(
"Topic") = "OS Version"SecondRow(
"Data") = Environment.OSVersion.ToString()BPI_Dataset.Tables(
"BPI_Table").Rows.Add(SecondRow) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickMyBindingSource.Filter =
"Topic = 'OS Name'" 'you can use instead of button click a node click in your tree view 'but remember you have a tag property in every node you make 'you can put your node.tag the same text in your data table like for example ' your node.text = "operating system" , make your node.tag = "os Name" as you used it in your data table 'filter your bindingsource by your node.tag (Mybindingsoure.Filter = String.Format("Topic = '{0}'", e.node.tag)'other wise make your table.Topic text exactly teh same like your node.text and use your node.text to filter your bindingsource
End SubEnd
Classhope this will help
L. von Wyss
Thank you so much for your help!!!
-- Jim
Sussch
Anybody I see a lot of people looking, but nobody replying... are you not replying because my post doesn't make sense or because you don't have an answer
Please let me know... I'm really struggling and any feedback would be greatly appreciated!!!
-- Jim
Attila Hajdrik (exMSFT)
Thank you so much!!! That is exactly what I'm trying to accomplish! Looks like I have some work to do, but that definitely pointed me in the right direction.
Just so I know, once I get everything the way I want, I plan to add a button or menu item to allow the user to export the data to an XML file... is that something feasible to do from the dataset I'm creating I'm not at that point, but I just want to make sure I won't have to completely redo my code with a "should have done it this way" type of thing.
Thanks again!
-- Jim
cptscottie
Hi Jim,
I'm sorry that I haven't responded but I haven't responded because I'm pretty much a novice in ADO.
But then I looked carefully at your problem and found myself wondering
What imports and references you've made and how BPIDataSet.BPI_DT.NewRow is defined elsewhere