Database Question

I have two forms, a Main Form of a CookBook, and another form that should Add Data to the CookBook. The first form has bind navigator, DataSet, BindingSource and a Table Adaptor. Now, when the user clicks an "Add" button, a modal form appears where the user has three fields like Title, Ingredients and Recepie. When he writes those fiels, and clicks the add button, everything will work fine and the record will be added to the database. How do I do this tehnically Do I need to add all the stuff, tableadaptor, bindingsource, etc.

Answer this question

Database Question

  • golfdude54

    All right.

    Well, it did not made anything clear ... I still dont know how to do this in code and what the necesary steps are. So ... I did this:

    This is the Main From with everything tied to it, it works fine!

    http://i44.photobucket.com/albums/f47/cain152/maincs.jpg

    When the user pressess "Add" this pops up in a modal dialog

    http://i44.photobucket.com/albums/f47/cain152/adddata.jpg

    The user types something in those fields ... and then he pressess "Add" which causes the DataBase to update, close the modal dialog and revert back to the main form.

    This is the code for the AddData.cs form of the button btnAdd

    http://i44.photobucket.com/albums/f47/cain152/btnAdd.jpg

    Now, my question is ... what DO I write here ...

    *Note that the AddData.cs does not have any data components tied to it ...

    Thanks a lot in advance.


  • My Vizai

    Hi,

    Yes, Nefer. Just dev another form with all the stuff you want like button, datagridview or so, and to update the exact data in the database. Dont forget when the updating has done, back to the first form you'd refresh it.

    Thanks



  • linzbfc

    Ok, I studied Apress Visual C# Express from novice to professional, but there are to few clues relating to this matter. How do I do this in code, what are the necesary steps When the form loads, I create a new table adaptor Or .... That's my main problem.
  • JGP

    Hi,

    When you click the mainForm, popup a childform (or just implement all the things in a form by panel), then some textbox or datagridview (it depends on yourself) for user to input the info insert, then write the code in something like a button click event in childform. The code make the insert issue and close the childform back to the mainForm.

    About the insert issue, you can do it using dataAdapter.Update (Insert command write in dataAdapter.InsertCommand)

    For more info : http://msdn2.microsoft.com/en-us/library/system.data.common.dbdataadapter.updatecommand(VS.80).aspx

    Hope it make you have a clearer image :-)



  • fbiots

    Can anyone help ....
  • Database Question