I know that if I have a program with a connection to an Access database, if I change the name of a table in the database, when I try to access that table from within the program, it's going to throw an exception.

My question is, how do I cause the dataset to use the new table name? Do I have to recreate the dataset? The dataSOURCE reflects the new table name, but the dataset is still using the old table name.

Hi Toulinwoek,

Wouldn't it be nice if that were dynamic? :lol: How you might do this and whether you would want to probably depends on context. If you're dealing with strongly typed datasets, then you would have to update your data adapter and dataset. However, this is usually pretty easy from a right-click menu in design view when you click on your data adapter (if you're using Visual Studio).

ADO.NET, as far as I know does not dynamically accomodate changes to the database schema. But it's still the best thing around (IMHO) because Visual Studio can autogenerate all the code for you when you make changes like this.

In general, I think your code will have to have the table name for any queries you run against the database. Obviously, you could create some kind of class that would extract the database schema and map table names so that your code could handle changing of table names, but this wouldn't be worth it unless you expect frequent and ongoing table name changes.

Cheers,
Steve

I know that if I have a program with a connection to an Access database, if I change the name of a table in the database, when I try to access that table from within the program, it's going to throw an exception.

My question is, how do I cause the dataset to use the new table name? Do I have to recreate the dataset? The dataSOURCE reflects the new table name, but the dataset is still using the old table name.

Thanks for the info.
What happened was when I created the database, I was using a particular naming convention for the tables. As an afterthought I added another table and didn't really think about the naming until I was building the forms in the IDE. I decided just for the sake of consistency to rename that table, but noticed that the dataset didn't update. It's not really an issue.

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.