Results 1 to 4 of 4

Thread: Database "Ran out of Book"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183

    Unhappy Database "Ran out of Book"

    I’m currently using VB.Net for beginners book and at the time this is all I have or else I would not be posting such a stupid Question.
    My problem is this! I have made up a Front end for a simple Database that uses text Boxes to display the Data. I have added buttons to my form that let me step thru my database to view the contents. All that works just fine, but the Book stops there.
    Now I have added 2 more buttons, a button New and a button Save.
    Can I use that same Form to Add to my Recordset ?
    And would someone please be so kind to point me in the rite direction, or at least explain to me what I need to do next?
    Thanks!

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Are you using databinding? If so then New button will do something like this:
    VB Code:
    1. cm.AddNew()
    Where cm is the CurrencyManager, the manager of databinding in your form. AddNew causes all the textboxes to be cleared and ready for a new data. Remember that if you are binding comboboxes or radiobuttons then you must have a default value set for the fileds they are bound to in the dataset, or it will not work.

    After entering your data you may need to ignore the changes and return back, so you have to use RejectChanges method of the Dataset Table you are working with.

    To save the data you must call EndCurrentEdit method of currencymanager and after verification of data use Update method of the dataadapter.

    If you are not binding then you can add a new row to the dataset, clear textboxes and wait for the user to enter the data and click the save button. On saving you verify the data and enter into the new row of the dataset, after that you can update the database.
    Last edited by Lunatic3; Oct 12th, 2003 at 01:46 AM.
    '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

    Thread Starter
    Addicted Member
    Join Date
    Dec 2002
    Location
    Central US
    Posts
    183
    Yes I’m using data binding in Text Boxes, but I still don’t understand (sorry)
    I’m starting out with
    VB Code:
    1. Dim cm As CurrencyManager
    2. cm.AddNew
    now do I need to declare all members of the Table??? and if so how?
    Thanks a million!

  4. #4
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    The currency manager should be the manager of databinding you are using, so just declaring it is not enough. If I were you, i declared cm publicly so it can be accessible through the procedures. Then after that, somewhere like in the form load event you have to set the cm. Something like this:
    VB Code:
    1. cm = CType(Me.BindingContext(your_dataset_here, "bounded_tablename_here"), CurrencyManager)
    After using cm.AddNew, you dont have to 'declare all members of the Table'. Each bound element of form is now ready for input of a new record.
    '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

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