Confusion about ADO.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • romcab
    New Member
    • Sep 2007
    • 108

    Confusion about ADO.net

    Hi guys,
    I'm currently studying ADO.net and I used video which I got from learnvisualstud io.net. I follow a the tutorial and I was able to create a simple apps which can load its content. My problem right now is that when I clicked the add and save, I was able to add/save but the database is not updated. Upon investigating the source code, I have'nt found a code regarding connection. What i remember is that during adding of the datasource, all of them are popup and created automatically. My question right now is how can I see/update the data on the database? I put code generated below.

    [CODE=cpp]namespace ADOTest2
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeCompo nent();
    }

    private void customerBinding NavigatorSaveIt em_Click(object sender, EventArgs e)
    {
    this.Validate() ;
    this.customerBi ndingSource.End Edit();
    this.customerTa bleAdapter.Upda te(this.myCompa nyDataSet.Custo mer);

    }

    private void Form1_Load(obje ct sender, EventArgs e)
    {
    // TODO: This line of code loads data into the 'myCompanyDataS et.Customer' table. You can move, or remove it, as needed.
    this.customerTa bleAdapter.Fill (this.myCompany DataSet.Custome r);
    }

    private void button1_Click(o bject sender, EventArgs e)
    {
    Form2 f2 = new Form2();
    f2.Show();
    }
    }
    }[/CODE]
    Last edited by Shashi Sadasivan; Jan 23 '08, 04:41 AM. Reason: adding code tags
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    when you do the Update if any changes are made to the dataTable, the changes are update to the database.
    the Update method also returns the number of rows that have been updated to the database. (that one way of checking)
    if you do want to make sure that the database has the right values then Fill the datatable again as you did in Form_Load

    Else, open the database console and query for the changes you made :)

    Comment

    • romcab
      New Member
      • Sep 2007
      • 108

      #3
      Originally posted by Shashi Sadasivan
      when you do the Update if any changes are made to the dataTable, the changes are update to the database.
      the Update method also returns the number of rows that have been updated to the database. (that one way of checking)
      if you do want to make sure that the database has the right values then Fill the datatable again as you did in Form_Load

      Else, open the database console and query for the changes you made :)

      Hi,

      I can edit/add on the UI and upon next/previous the changes is fine. But if I close the application and run the program again, the changes I made is not save. When I looked at the content of the database using ShowTable data, database is not updated. Aside from that, why I can't see the code that perform connection to the dbase?

      Comment

      Working...