Database choice?

  • Thread starter Thread starter Orion Tatsihama
  • Start date Start date
O

Orion Tatsihama

Guest
Im creating a program and am trying to decide how to store the information entered. I want it to be able to be displayed in a noneditable way (but be able to be edited through another form). I would like to use a text file if possible...if not, I need an offline database. I know nothing about databases (except mySQL) and since this is going to be a distributed program, I dont want the user to need anything extra to use it. What is my best option?

I would like the information to be displayed in a grid, but not be editable through the grid itself. I would also like the user to be able to sort the data by any field, such as Title, Lenght, etc.

I am really new to all of this...so Im sorry if Im not being clear. Ask me if you need more information. I am using Visual Basic .NET
 
Hi,

displaying information in a grid, making it not editable, etc. has not very much to do with the choice of the database but rather with the the properties youre setting for the control displaying the data (think od DataGrid).
More over there are controls which intrinsically not meant for editing data displayed in it but for displaying it only (MSFLEXIGRID,MSHFLEXIGRID, ListView...)
For the rest, to give you a more precise answer, I think one needs to know more about your project.

About the fact you "dont want the user to need anything extra to use it"... Say, you can create a project with an Access database as a back end and after that distridute it on a PC which doesnt have Access on it.

Regards,

Shurik12.
 
My program is called DVlog. Its a DVD "database" program where you enter information on dvds that you own and it keeps track of them. Right now, Im just trying to get the Adding and Displaying features working. The fields are: Genre, Title, Rating, Length, (Number of) Disks, Special Edition? (Yes/No), and Year.

This is a demo entry in my text file database:
Anime\tGTO\tNR\t112\t1\tNo\t2002\tGreat Teacher Onizuka Ep. 1-4

More over there are controls which intrinsically not meant for editing data displayed in it but for displaying it only (MSFLEXIGRID,MSHFLEXIGRID, ListView...)
I hear a lot about MSFLEXIGRID and MSHFLEXIGRID but I have no idea what those are.

About the fact you "dont want the user to need anything extra to use it"... Say, you can create a project with an Access database as a back end and after that distridute it on a PC which doesnt have Access on it.
Yes, thats what I mean.
 
Will the fact that I use VB.NET Standart effect the use of the things on that site? I look at them and I dont see anything about DAO, AOD, or MSFlexigrids in my program. :(
 
The VB.NET syntaxis itself differs a good deal from that one of VB 6 (5...).
But the definitions of ADO, Flexigrid etc. remain the same.
Try to have a look in the help files of your VB.Net Standard.

Regards,

Shurik12.
 
Is it possible to use the text file database I setup? Or an access database? Im sorry...Im really new when it comes to this stuff.
 
First of all you should not feel sorry. Thats what forums are for: to ask questions and get answers.

If its all about ONE table youre going to have you can perfectly use your txt file as the data container.
If you have more then one, then relational databases such as
Access, MS SQL, Oracle, Sybase, mySQL etc. come into play.
By the way you mentioned you had some experience with mySQL.
All the mentioned databases are relational. So there should be nothing new for you as far as the "idea" of a relational database concerned.
 
Thats good to know!
Now...I guess my only issue is taking the data in the text file and displaying it in a "spreadsheet" or "grid" type display. I also heard that you cant edit/delete a line of a text file, you have to rewrite the entire file omitting that line or replacing it with the edited line...is that true?
 
No problem :)
Thanks for all your help!

To anyone whos reading this, feel free to help me out too, please. :)
 
Hi again,

If you choose a .txt-file as the place to strore the data, have a look at the "Open"-statement, "Input"-function, etc... in the help files. It should give you an idea how to work with the text files.

One more thing, if you have an opportunity to do it in Access or even in Excel go for it.


Regards,
Shurik12
 
The main reason I want to use text files is cause I can use my own file extentions. :) Ill checkout the statements and functions. Thanks.
 
I have no idea where to start with XML...
I looked at some XML resources but I dont get it.
 
To use a text file as a data container is simple.

Here is an example of how to open and read a text file in visual basic 6.

I dont have the .net version of visual basic , but it be similar in practice.

----------------------------
Example of how to open a file in visual basic.
----------------------------


Dim importfile As Integer
importfile = FreeFile

Dim fileinfo as string

Open "c:\whatever.txt" For Input As #importfile

If Not EOF(1) Then
Do
Input #importfile, fileinfo get some info from the file.
Loop Until EOF(1) keep looping until its the end of the file.
End If
Close #importfile



--------------------

This should give you an idea of what your code should look similar to.

Check in the help file for information on how to "open" a file.

Also look in the help files for examples of how to work with arrays.

If you would like, I would be happy to build a simple application using VB 6 which can read and write data to a text file, and post it online for download.

Would anyone else like me to build an example application for download?

david
mouseslinger@hotmail.com
 
To use a text file as a data container is simple.

Here is an example of how to open and read a text file in visual basic 6.

I dont have the .net version of visual basic , but it be similar in practice.

----------------------------
Example of how to open a file in visual basic.
----------------------------


Dim importfile As Integer
importfile = FreeFile

Dim fileinfo as string

Open "c:\whatever.txt" For Input As #importfile

If Not EOF(1) Then
Do
Input #importfile, fileinfo get some info from the file.
Loop Until EOF(1) keep looping until its the end of the file.
End If
Close #importfile



--------------------

This should give you an idea of what your code should look similar to.

Check in the help file for information on how to "open" a file.

Also look in the help files for examples of how to work with arrays.

If you would like, I would be happy to build a simple application using VB 6 which can read and write data to a text file, and post it online for download.

Would anyone else like me to build an example application for download?

david
mouseslinger@hotmail.com
 
The .net version of that code is almost completely different, mouseslinger :)
 
It is? Well I have no idea about converting it...I have the Standard version so it wouldnt convert it for my either. I found a script that can split the info from a file into an array, is there somewhay I can use that?
 
How to do it

The person who said that XML is the way to go is correct.. too bad he didnt say anything else about how to do it.

This is what Ive done in an application of my own in which I save all my information in a "text" file as you put it (actually an .xml file; but can be read just as a text file in Notepad or whatever).

Try this:

First of all, on your toolbar click on "Project" and the click on "Add new Item".. from the list, choose "XML Schema".

This will add a new .xsd file to your program. In your program window go to that file and create a schema (a graphical representation and hierachal view of the way the data will be held). Press F1 to go to the help menu and read about Elements and Complex Types to create your schema.
Basically a schema is the "skeleton" of your database. It will give you something to populate. Once you start populating it you will save the results as a .XML file.

First of all put the following in the form that you are going to use to enter data.
This is how I coded it (not perfect as I am new at this also)

*( put this underneath "Inherits System.Windows.Forms.Form")

Public ds1 As New DataSet()
Dim xmlDoc As New Xml.XmlDataDocument()

*( put this underneath your form load event) *

ds1.ReadXml(fileOpen)

file open equals the name and location of the .xsd file you created... this loads the database structure into the dataset.

What you can do from here is tie the ds1 into a datagrid, of course you have to do this from code though.

datagrid1.datasource = ds1


Once you have entered whatever data into the datagrid, do this to save the information into a XML file.

private Sub saveXMLFile()
Dim sDialog As New SaveFileDialog()
sDialog.FileName = ("MyXMLFile") & ".xml"
sDialog.Filter = "XML files (*.xml)|*.xml"
If sDialog.ShowDialog = DialogResult.OK Then
Dim wstream As New _
System.IO.StreamWriter(sDialog.FileName)
ds1.WriteXml(wstream, XmlWriteMode.WriteSchema)
wstream.Close()
End If
End Sub

*note that "MyXMLFile" can be whatever you want
The file is now saved as an XML file. Pretty nifty!

Next make the form that you want to use to display the data.

First of all create a datagrid on the view form and set its source to your dataset (you have to do this in code)

datagrid1.datasource = ds1

Next, because you dont want anyone to be able to modify the contents of the database, set the read-only attribute to true.

datagrid1.readonly = true

Now, this is code to load the XML file:

Dim fsReadXml As New System.IO.FileStream _
("MyXMLFile.xml", System.IO.FileMode.Open)
Create an XmlTextReader to read the file.
Dim myXmlReader As New System.Xml.XmlTextReader(fsReadXml)
Read the XML document into the DataSet.
ds1.ReadXml(myXmlReader)
Close the XmlTextReader
myXmlReader.Close()


The datagrid will be populated with the info you entered on your other form.

Hope this helped. Let me know if you need clarification.
 
Back
Top