Hello everyone!

First of all this is about DataSets. I made a table with some examples in MS Access and now I need to add new rows into this table from C# console application. I added DataSet (MSAccessBase) and used TableAdapter for adding MS Access's table into project Solution.

I tryed many things to add new row into MS Access table but always unsuccessful. I have no idea why this code doesn't work:

class Program
    {
        static void Main(string[] args)
        {
            //MSAccessBase is the name of added DataSet (for table Person from MS Access database)
            MSAccessBase thisBase = new MSAccessBase();

            PersonTableAdapter personTA = new PersonTableAdapter();
            personTA.Fill(thisBase.Person); //fill the DataTable

            DataRow rowPerson = thisBase.Person.NewRow();
            rowPerson["ID"] = "2";
            rowPerson["Name"] = "Peter";
            rowPerson["Surname"] = "Colton";
            rowPerson["Email"] = "peter.colton@gmail.com";

            thisBase.Person.Rows.Add(rowPerson);
        }
    }

Any help is the most welcome!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.