Results 1 to 3 of 3

Thread: Help on saving a simple data to a database

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2004
    Location
    Some where on Earth
    Posts
    98

    Help on saving a simple data to a database

    hi guys!

    Alright, i want to start off small by creating a name field(txtName) and a age(txtAge) field and save to a database in Access. Lets say that i have a table called "Human" and it has "Name" and "Age" fields in it.

    I have done the connection to the database using VB.net in this steps below:

    Tools-->Connect To a Database-->Provider(Tab bar)-->MS JET 4.0 OLE DB provider-->locate where the .mdb file-->test connection.

    The connection is successful. Now im stuck here! I dont know how to code to make it store the name and age to a database. Can you please provide a full code example how to store those data in the database when i click a button. I just need to know the basic then i can keep the ball rolling! Hope you could help me! Thanks!!
    Anime is what i LIVE for, BREATH for, and DIE for!

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    MSDN
    www.google.com
    Lots of examples, tutorials, etc, etc there, if only you care to do a search and read!
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Help on saving a simple data to a database

    Originally posted by RedDevil
    hi guys!

    Alright, i want to start off small by creating a name field(txtName) and a age(txtAge) field and save to a database in Access. Lets say that i have a table called "Human" and it has "Name" and "Age" fields in it.

    I have done the connection to the database using VB.net in this steps below:

    Tools-->Connect To a Database-->Provider(Tab bar)-->MS JET 4.0 OLE DB provider-->locate where the .mdb file-->test connection.

    The connection is successful. Now im stuck here! I dont know how to code to make it store the name and age to a database. Can you please provide a full code example how to store those data in the database when i click a button. I just need to know the basic then i can keep the ball rolling! Hope you could help me! Thanks!!
    sample:
    VB Code:
    1. 'cn is a connection
    2.  Dim cm As New OleDbCommand("insert into sampletable(name,age) values(@n,@a)", cn)
    3.         With cm
    4.             .Parameters.Add("@n", TextBox1.Text)
    5.             .Parameters.Add("@a", Textbox2.text)
    6.             .ExecuteNonQuery()
    7.         End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width