Helpful Information
 
 
Category: .Net Development
adding a record and updating a dbase with a dataset

im am trying to add a record to a dbase table in access using a dataset to update the dbase.


my code:

DataTable myTable;
myTable = dsTopics1.Tables["GraphPosts"];
DataRow myDataRow;
DataRowCollection rc = myTable.Rows;
myDataRow = myTable.NewRow();

myDataRow["StudentName"] = tbName.Text;
myDataRow["Topic"] = tbTopic.Text;
myDataRow["Post"] = tbPost.Text;
myTable.Rows.Add(myDataRow);



oleDbDataAdapter1.Update(dsTopics1);




when i press my submit button, i get the following exception:

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

and this line of code is highlighted

DataRowCollection rc = myTable.Rows;

i am using access dbase and am trying to create a simple bulletin board in ASP.NET using visual studio.net.

can anyone help?
regards
das

You've probably already worked this out but hey...

try:

myTable = dsTopics1.Tables[0];

The errors you got is related to your database connection.
Check your datbase connection. If you show the full coding, maybe I can give an idea.










privacy (GDPR)