Visual Basic > Visual Basic Forums > Visual Basic General > My First DATA Base Application
Ask a questionAsk a question
 

AnswerMy First DATA Base Application

  • Tuesday, November 03, 2009 11:49 PMShariqDON Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I want to Make DATA Base Application ! Who Save DATA in XML
    THis is New stuff for me , Like you Can See My Title of This thread.....

    So Please Give me Some Clue ! How to Start...

    Which i tool i use ......

    Thanks
    www.shariqdon.media.officelive.com

Answers

  • Wednesday, November 04, 2009 4:20 AMCrazypennie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code


    This is the basic stuff that you need.


    Public Class Form1
        Dim DtaSet As New DataSet
        Dim WithEvents DGrid As New DataGridView
        Dim WithEvents button1 As New Button
        Dim Tbl As New DataTable
        Public PathName As String = "C:\Tst\"
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Size = New Size(600, 700)
            Me.Location = New Point(10, 10)
            Me.StartPosition = FormStartPosition.Manual
    
            'A datagridview to see and edit the data
            DGrid.Width = 400
            DGrid.Height = 600
            Me.Controls.Add(DGrid)
    
            'Show the data in Tbl in the datagridview
            DGrid.DataSource = Tbl
    
            'A dataset to manage the data
            DtaSet.Tables.Add(Tbl)
    
            'A table to hold the data
            Tbl.Columns.Add("Items")
            Tbl.Columns.Add("Description")
            Tbl.Columns.Add("Value")
            Tbl.Columns.Add("Total")
            Tbl.Columns.Add("Extra1")
            Tbl.Columns.Add("Extra2")
            Tbl.Columns.Add("Extra3")
    
            ' A save data button
            button1.Location = New Point(440, 600)
            button1.Text = "Save Data"
            Me.Controls.Add(button1)
    
            If Not IO.Directory.Exists(PathName) Then  'If it don't exist
                IO.Directory.CreateDirectory(PathName) 'Create a new directory for the database 
            End If
    
            If IO.File.Exists(PathName & "Main.xml") Then
                Tbl.ReadXml(PathName & "Main.xml") 'Load existing data if exist 
            Else
                Tbl.WriteXml(PathName & "Main.xml") 'If dont exist, create it
            End If
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Tbl.WriteXml(PathName & "Main.xml") 'save the data entered in the DataGridView
        End Sub
    
    End Class
    


    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:08 PM
    •  
  • Wednesday, November 04, 2009 5:15 AMCor LigthertMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer


    ShariqDon,

    Be aware that Data in XML is not an equivalent of a database.

    XML is just a way of notate data (encalapse it between nodes).

    A Database don't need that.

    If you want a database then use one SQLExpress is free, if you install in from the Web it should not be a difficult job.

    http://www.microsoft.com/express/sql/download/

    You need at least the runtime and the management tool to use it.


    Success
    Cor
    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:09 PM
    •  
  • Wednesday, November 04, 2009 7:08 PMCrazypennie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer


    Datagridview is a good tool,

    for the other controls, check "Control.DataBindings" Property

    To manipulate the data in your application, read about dataset and dataTable

    As Cor said, If you are using the .Xml files, you do not have a Database, You have to create it in your application.
    If you only have a small amount of data, this may be a solution, but if the amount of data is more than that, You should use a database (Easier and much more powerful)

    If you want to learn to use a database, Cor Suggestion to start with SQLExpress is a very good one
    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:08 PM
    •  
  • Thursday, November 05, 2009 3:39 PMCrazypennie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    ShariqDON,

    I am sorry to answer you this, but there is way to much thing to explain in doing a DB to be explain "A to Z" in a forum.

    You should start to study:

    -What is a "DataSet" and how it works

    -What is a "Datatable" and how it works

    -What is "DataBinding and DataSource" and how it works

    -What is a DataBase and how it works

    -and may be what is an XML file

    Then, You will be able to come back with some more targeted questions
    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:08 PM
    •  

All Replies

  • Wednesday, November 04, 2009 4:20 AMCrazypennie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code


    This is the basic stuff that you need.


    Public Class Form1
        Dim DtaSet As New DataSet
        Dim WithEvents DGrid As New DataGridView
        Dim WithEvents button1 As New Button
        Dim Tbl As New DataTable
        Public PathName As String = "C:\Tst\"
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Me.Size = New Size(600, 700)
            Me.Location = New Point(10, 10)
            Me.StartPosition = FormStartPosition.Manual
    
            'A datagridview to see and edit the data
            DGrid.Width = 400
            DGrid.Height = 600
            Me.Controls.Add(DGrid)
    
            'Show the data in Tbl in the datagridview
            DGrid.DataSource = Tbl
    
            'A dataset to manage the data
            DtaSet.Tables.Add(Tbl)
    
            'A table to hold the data
            Tbl.Columns.Add("Items")
            Tbl.Columns.Add("Description")
            Tbl.Columns.Add("Value")
            Tbl.Columns.Add("Total")
            Tbl.Columns.Add("Extra1")
            Tbl.Columns.Add("Extra2")
            Tbl.Columns.Add("Extra3")
    
            ' A save data button
            button1.Location = New Point(440, 600)
            button1.Text = "Save Data"
            Me.Controls.Add(button1)
    
            If Not IO.Directory.Exists(PathName) Then  'If it don't exist
                IO.Directory.CreateDirectory(PathName) 'Create a new directory for the database 
            End If
    
            If IO.File.Exists(PathName & "Main.xml") Then
                Tbl.ReadXml(PathName & "Main.xml") 'Load existing data if exist 
            Else
                Tbl.WriteXml(PathName & "Main.xml") 'If dont exist, create it
            End If
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Tbl.WriteXml(PathName & "Main.xml") 'save the data entered in the DataGridView
        End Sub
    
    End Class
    


    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:08 PM
    •  
  • Wednesday, November 04, 2009 5:15 AMCor LigthertMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer


    ShariqDon,

    Be aware that Data in XML is not an equivalent of a database.

    XML is just a way of notate data (encalapse it between nodes).

    A Database don't need that.

    If you want a database then use one SQLExpress is free, if you install in from the Web it should not be a difficult job.

    http://www.microsoft.com/express/sql/download/

    You need at least the runtime and the management tool to use it.


    Success
    Cor
    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:09 PM
    •  
  • Wednesday, November 04, 2009 6:10 PMShariqDON Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

       Crazypennie !
                        Thats Nice ... Thanks

    I have a Few Questions:

    You Use DataGridView Tool For Database Can I use Another Tools Like
    Textbox or Another.  ( i need suggesstion )

    What the best tool For Data Save And And
    i also Able to View My data In my APplication...

    Thanks;



    www.shariqdon.media.officelive.com
    • Edited byShariqDON Wednesday, November 04, 2009 7:18 PM
    •  
  • Wednesday, November 04, 2009 7:08 PMCrazypennie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer


    Datagridview is a good tool,

    for the other controls, check "Control.DataBindings" Property

    To manipulate the data in your application, read about dataset and dataTable

    As Cor said, If you are using the .Xml files, you do not have a Database, You have to create it in your application.
    If you only have a small amount of data, this may be a solution, but if the amount of data is more than that, You should use a database (Easier and much more powerful)

    If you want to learn to use a database, Cor Suggestion to start with SQLExpress is a very good one
    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:08 PM
    •  
  • Wednesday, November 04, 2009 7:44 PMShariqDON Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    hi CrazyPenine can you translate your code:

    how to your Code Save Data...?
    www.shariqdon.media.officelive.com
  • Thursday, November 05, 2009 3:39 PMCrazypennie Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    ShariqDON,

    I am sorry to answer you this, but there is way to much thing to explain in doing a DB to be explain "A to Z" in a forum.

    You should start to study:

    -What is a "DataSet" and how it works

    -What is a "Datatable" and how it works

    -What is "DataBinding and DataSource" and how it works

    -What is a DataBase and how it works

    -and may be what is an XML file

    Then, You will be able to come back with some more targeted questions
    • Marked As Answer byShariqDON Thursday, November 05, 2009 7:08 PM
    •