Coding a simple database

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
Hello, I am not a really advanced vb.net coder but I would like to make a simple database that can be searchable.

Basically I have a list of about 1500 NPC names and for each one of those I have various information about them such as Location, Level, etc.

Currently the only way I can think to do something like this would be to make 1500 .dat files and put them in a directory and then have a button that when pressed with load all the .dat file names into a listview (set to detail view) and then when the user double clicks an item it will display the information (Location, Level, etc.)

(I haven't put all of the 1500 NPC and information into the .dat files yet)

This idea would make it easy to add more when needed but I don't think it would be searchable and even if it is, I would think there is a much better way to go about doing what I want to do.. so any help would be great. Thanks.
 
Recently, I've been a big fan of XML Serialization:

This will work for a reasonable number of objects, depending on the number of properties you want to Serialize.

However, this will not scale up as well as PDs sugestion of SQL Express -- the advantage is that you can manually open the XML file with notepad and make changes without any programming.
Visual Basic:
<Serializable>_
Public Class myNPC 
Sub New()
End Sub

' not positive on VB Syntax
Public Property Location as Point
    Get
        Return new Location(x,y)
    End Get
    Set
        x = value.X
        y = value.Y
    End Set
.... etc etc
End Property
End Class


...form code...
dim myNPCs as List<myNPC> = new List<myNPC>(1500)

Sub Button_Click(..)
Dim x as System.Xml.Serialization.XmlSerializer = new System.Xml.Serialization.XmlSerializer(GetType(List<myNPC>))

Dim fs as System.IO.FileStream = new System.IO.FileStream("myfile.xml", FileMode.Open)
x.Serialize(myNPCs, fs)
fs.Close()
End Sub

You could use a BinaryFormatter which is a more efficent method of Serialization but then you loose the abbility to manually edit the output file from Notepad or your choice text editor.

HTH
 
i think the actual database would probably work best but i have no experience with doing anything like that.. so if you could give me a little more info about how to go about using the SQL express to do what I need it would be really helpful.

and for the serialization thing, i have never heard of that before and it sounds like it might be better to to the actual database if i am going to spend the time to do all this work.
 
Back
Top