Working with Data—Adding Rows of Data
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| CSharp-Online.NET:Articles |
| Database Articles |
|
© 2006 Jeffery Suddeth |
Adding Rows of Data
We obviously need to add new rows to the table, too. To create a DataRow object, we call the Table’s NewRow method. That method will instantiate a DataRow object and set its auto increment field for the primary key. Then, we can set the other values of the record and add the row into the Table’s Rows collection.
DataRow row = custTable.NewRow(); row["Name"] = "Evy"; row["Phone"] = "123-555-9876"; row["Email"] = "evy@evymail.com"; custTable.Rows.Add(row);
|

