I have a MS Access database file that I imported into my project as a data source. It's visible in my solution explorer.
I have a DataGridView in my form whose data source is set to that imported access file.
How can I set up my OleDbConnection (dim con) to be that data source?
Right now I have con set to the actual file access database file, but when I send queries, the changes are made to my actual access file, and not the data source within my project!
Dim con as OleDbConnection = new OleDbConnection("***database.mdb")
Within the above *** string it points to the databasefile located on my hard drive that I imported into my project. But when I send queries to my DataGridView it makes those changes on the file, not on the data source that I bound to the DGV.
I need a way to keep all the querying to one database... maybe have them linked?
THe problem is that when customers use this program, they will be given updated versions of the database file with new data.
When this program is finally compiled and sent out for use, how can they get the new data without having to reinstall the program? Is it possible that they just recieve the XSD file or what?
the XSD file is just a design time file. Your users will never see it. If you want to give them an updated database, you give them a new mdb file and copy it over the old one. The data source points to the Access file... it's not some magical data storage... it's a gateway. Allows you to see what databases you are connected to. So, yeah, you make changes to your data, it's going to update the database. That's the idea.
When I change the datasource property of the DGV to be the database file, it doesn't make changes to the actual database, only the database file imported into the project.
How do I make it so the changes are to the actual database file?
Personally, I never use the Data Source thing... I make all my connections manually...
ADO.NET works in a disconnected state by default... so changes you make aren't propagated back to the database until you tell it to do so (either by looping through the data, and running update queries, or by calling the .Update method of a properly connected and configured dataset/table.)
In short, whether you use a DataAdapter or a TableAdapter, you call Fill to populate a DataTable, edit the data, then call Update to save the changes. A TableAdapter is just a typed wrapper for a DataAdapter. You can either write all the code yourself or let the system do it for you but, either way, the data is retrieved and saved the same way.