none
How do I insert a new row into the database using Tableadapter configuration Wizard? RRS feed

  • Question

  • Hi all,
    I try to insert the new row into the table using TableAdpater Configuration wizard.
    There are three layer in my project. One is controller layer, second is model layer, third is UI layer.
    There are Testdataset at model layer and some tableadapter inside this dataset. let say Policy_IBTableadaper.
    There are mehtod at controller layer such as following.

    Policy_IBTableAdapter da_PolicyIB = new Policy_IBTableAdapter();
    da_PolicyIB.Fill(dataset.Policy_IB);

    public DataTable InsertPolicyIB()
            {
                return (DataTable)da_PolicyIB.GetData();
            }

    At UI layer,
    private void AddPolicy_Click(object sender, EventArgs args)
    {
    DataTable dt_IB = controller.InsertPolicyIB();
    DataRow row = dt_IB.NewRow();
    row["PolicyID"] = "IB00001";
             row["CompanyID"] = "0001";
             row["CategoryID"] = "1";
             row["PolicyCode"] = "GCR";
             row["PolicyNo"] = "ABCDEF09-00001";
             row["InsurerID"] = "1ACE";
             row["IsAgent"] = 1;
             row["EntityID"] = "ABE0001";
             row["CustomerID"] = "00001";
             row["DateEntry"] = "05/10/2009";

    dt_IB.Rows.Add(row);
    }

    No row is inserted into the table. I think I need to update the tableadpter but I can't execute the tableadapter at UI side.
    I try to solve the problem.If you have any idea to solve the problem, Pls let me know.
    If I know the solution, I will upload my solution.

    Thanks in advance
    Su Hlaing
    • Moved by Hua Chen Wednesday, October 7, 2009 6:50 AM ADO.NET issue (From:Windows Presentation Foundation (WPF))
    Tuesday, October 6, 2009 9:00 AM

All replies

  • Hello Su,

      It should be a ADO.NET issue.
     
      Move to ADO.NET forum

      Good luck.
    Please mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, October 7, 2009 6:48 AM