Databinding Designer - What if the data source or type changes?

joelmeaders

New member
Joined
Aug 16, 2013
Messages
2
Programming Experience
1-3
Hello, I am using VB.NET 2008 Express.

There are a million threads about unbound vs bound fields, custom bound or designer bound, and custom connections, datasets etc... If I were to use the data source wizard what would need to be done in the future if the source location or database type changes? Could the location and type be controlled from a settings menu in this way?

I already understand and have custom programmed my connections and datasets/tables in a test project an can access the data and display it on the form using a loop through control names and tags. In Access I never used bound forms or controls and have tons of code for handling everything dynamically so I don't know what's best in VB.NET. I was going to try an N-Tier setup but that option isn't possible in the express editions from what I've read.
 
I was going to try an N-Tier setup but that option isn't possible in the express editions from what I've read.
I'm not sure where you read that but it's not true.

If you use the Data Source Wizard to generate a typed DataSet then it will store the connection string in the config file by default. The reason for that is so that you can change it easily without having to recompile the application. As such, if the location of the database or the way you want to connect changes, you simply edit that config file, which is XML, by hand. This has limitations though. For instance, if you generate a typed DataSet from a SQL Server database then the table adapters will use SqlClient under the hood. As such, you are limited to only using a SQL Server database. If you generate the typed DataSet from an Access database then OleDb will be used under the hood. In that case, it may be possible to use other OLE DB data sources without having to recompile, but I've never tried so I'm not sure.

If you think that there's a chance that you might need to change the data source then you should generate your typed DataSet in its own library, which you certainly would do anyway if you were creating an n-tier application. What you can then do is simply generate a new typed DataSet from the new data source, either in the same project as the old one or a new project. As long as all the names and data types are the same as before, the application should just work.

Note that a lot of people get confused between using the Data Source Wizard and using the Data Sources window to generate data-binding. Many people will tell you that the former is bad because of the latter but they are two different things. I'm not in favour of the latter, although it does make things easier for the rank beginner, but I am definitely in favour of the former. I don't use typed DataSets but I do use the Entity Framework and it uses the same Data Source Wizard. Just because you generate a typed DataSet, you are not required to drag and drop to bind. You can still do all the binding yourself, just as you would with an untyped DataSet.
 
Back
Top