Need Recommendation On Best Data Storage Method

Hi everyone,

I'm just getting into the Visual Basic 2005. I knew VB6 pretty well, so this is kind of a big jump. I think with a recommendation on how to proceed, I can probably figure out how to continue, but I need a little help getting started.

What I want to do to help learn things is create an application that will show system information from the PC/server it is run on. 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 is currently empty.

I want the user to click on a "Gather Info" button that will gather all the information for the machine using (My Namespace methods) and hold them somewhere (memory, a datagrid, dataset) until needed. Then when a user clicks on the node in the left (Operating Systems for instance), I can have all the attirbutes that I gathered pertaining to OS show up in the right pane. When they click on a different node, the other information comes right up.

My thinking is to gather the information first so that it will be quicker to respond when the node is clicked on. I guess the right pane of the Split Container does not even need to be part of the data solution. That could be just a listbox to show information retrieved from the data source. Once the user closes the application, the information is no longer needed at all.

As a side note, the last thing I plan to do is to allow the information to be exported to an XML file (on the fly) if desired.

I don't think I need a full database, but I'm not very good with knowing all the new data storage solutions for VB 2005. If someone can give me an idea of what makes sense for a general direction to go, I would really appreciate it!

Thanks!

-- Jim



Answer this question

Need Recommendation On Best Data Storage Method

  • aek

    If I were you, in Word I'd insert a symbol like | between the word and definition and then I'd write the file out into a text file. You don't need any more than than to make a good little project.

  • Gerardo Cignarella

    You don't need SQL for this at all. There are system information programs all over windows and they don't use SQL. If they did, only systems with SQL could run them and that's a very low percentage of systems. If you take a look at WMI (System.Management) almost all system data is accessible. If you want to develop a hierachy to look at system objects in a treeview, the task is not storage, it's organization. I have seen some systems that are implimented in htm and script. But power of such a system is in the organization of an object hierachy.

  • Henri De Veene

    hi,

    i guess htis tutorial might help you

    http://www.programmersheaven.com/2/Les_VBNET_15_p1

    hope that helps



  • Antonio Ooi

    Thanks for the response!  It will probably take me a day or two to look into serialization a little further.  Hopefully this will make sense for what I'm trying to do. 

    In order to work with the data in the app before serializing, will I need to add anything to VB - like a Data Set or anything to create the data structure   Or do I just serialize it and then pull it up as needed

    Thanks again!

    -- Jim


  • Wout

    Hi Jim,

    This one seems pretty easy.

    One of the things I've done for something like you are doing is to make up a complex data structure, just as complex as you like.

    When I want to store (persist) it, I can serialize it. If there are multiple versions of structures, I can define a dictionary of type DATASTRUCTURE (The one you designed) I can store all of the structures in there and simply serialize the dictionary. This works with very few restrictions, for example you can't stick no serializable objects in there such as a menubutton and serialize them.

    To read just unserialize into the dictionary or arraylist.

    Here's some sample code:

    Public Sub LoadMasterDatabase()

    'Deserialize and read the Items and Icon databases

    Dim name As String = GetRTMFilename()

    If File.Exists(name) Then

    Dim fsi As New System.IO.FileStream(name, IO.FileMode.Open) ' Open the dictionary in the defaulting directory

    Dim BinFormatter As New BinaryFormatter()

    Dim obj As Object

    Dim i As Integer

    ItemDB.Clear()

    Try

    obj = BinFormatter.Deserialize(fsi)

    ItemDB = (CType(obj, Dictionary(Of Integer, psec)))

    Catch e As SystemException

    End Try

    fsi.Close()

    BinFormatter = Nothing

    End Sub

    Public Sub WriteDictionaryToDatabase()

    Dim Outfile As String = GetRTMFilename()

    Dim Fso As New System.IO.FileStream(Outfile, IO.FileMode.Create)

    Dim BinFormatter As New BinaryFormatter

    Try

    BinFormatter.Serialize(Fso, ItemDB)

    Finally

    Fso.Close()

    End Try

    End Sub

    Don't forget to import system.text and system.io



  • Matt B

    Sound good, but after I put the | between words

    What code that I'll use, the one you had here

    Public Sub LoadMasterDatabase()

    'Deserialize and read the Items and Icon databases

    Dim name As String = GetRTMFilename()

    If File.Exists(name) Then

    Dim fsi As New System.IO.FileStream(name, IO.FileMode.Open) ' Open the dictionary in the defaulting directory

    Dim BinFormatter As New BinaryFormatter()

    Dim obj As Object

    Dim i As Integer...

    regards

    oscar



  • ペレイラ

    Hello ReneeC

    I need someting simple but a the moment some kind of hard

    I had a 144 words every one with the own defenition

    I had this on MSWord but I can put it into excel if is need

    I can use all the help that I can get it !

    regards

    oscar



  • Cwoja

    Oscar,

    For something this simple... you don't need a binary serialization.

    Use a flat text file for your database.

    Each time you read a record in a for loop, you can do this:

    Dim A() as string = split(record,"|")

    For or each record A(0) will have the word and A(1) will have the definintion

    You could store those in a .Net Dictionary of type (string, string) soring each key value pair. If you wanted to, that dictionary could be serialized.

    So now you have an approach and the tools. It's up to you to put it together.



  • Rekoob1

    OK, I think I'm now heading in the right direction to keep this simple yet effective. I think what I need is a dataset (with no DB connection) to hold all my information in memory. Then I can query the dataset to fill my listbox with the info I need when a user click on a node in the left pane. After I get all that working, I'll look at serialization to allow the user to export the data to an XML file.

    But I'm having some problems understanding how I want 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.Click

    Dim anyRow As DataRow = BPIDataSet.BPI_DT.NewRow

    anyRow.TopLevel = "System Information"

    anyRow.Topic = "OS Name"

    anyRow.Data = My.Computer.Info.OSFullName

    BPIDataSet.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


  • Dave S. Anderson

    Helly Jim

    Did you solve the issue, because I'm in the same situation

    I was told to use SLQ database express, but I can get it into my - Add New Item window

    my regards

    oscar



  • Need Recommendation On Best Data Storage Method