WHAT'S NEW?
Loading...

How Databinding works if in case to make modification on table’s columns?


In Visual Basic.Net Windows Form DataBinding and ADO.NET on how to Setup Connection Wizard to connect database access to bind data from Windows Form Application. Now, let’s take a look how it work as data passes from Windows Form to MS Access Database and how to manage Server Explorer as part of the Data connection where in database was already located.

In this tutorial, I am using VisualStudio 2012 Ultimate, if you’re using previous version is almost identical, only the colors, icons, and other options are not same as VS 2010 because of some changes made. The one I like in VS2012, you’re allow to search windows such as Toolbox, Solution Explorer, Data Source, and other windows if not visible in your default view. If you’re now using VS2012, its looks like old windows but is doesn’t measure that. Indeed, it’s faster and light weight to use compare in previous version.  Fortunately, a lot of features is now available in Visual Studio 2012.

Now, if you had already add Database using Connection Wizard, it will automatically appear your Database file (act as Dataset a local copy of your Database) in a Data Sources Windows, and at the same time on your Solution Explorer it added new objects such as your Database and Database Dataset.

Once it has already added, in Server Explorer Window also added Data Connection from your database, Server Explorer allows you to retrieve data, add, and make some modification of your entry. However, make sure to create a copy of your file to your project’s output directory during Data SourceConfiguration Wizard so that every time you run the program, it will automatically load whatever made changes on your database. Your file can be found on folder bin/Debug/your_database_name. In this option will prompt a message.
Visual Studio Data Connection Wizard
Click Yes. If you click No, the database will remain its path location where it already saved.

Did you try or mistaken not to able to drag and drop your tables or columns name using Server Explorer Window? Actually, you cannot drag because this Server Explorer serves to manage your database connection as part of your database and tables. In Data Sources Windows, you’re allow to drag whatever you want either a table or any columns to choose any of the following Textbox, ComboBox, ListBox, and Label apply on your Form.

This is how it looks your Data Sources and Server Explorer Windows.
Visual Studio Data Sources and Server Explore Windows
In Databinding, sometime it’s hard to analyze and understand where the data passes through. Next, let’s examine how data works if some modification happen in the database tables and make some changes its columns or to add/delete/modify entry. What if I want to make changes my columns name or add another fields in my table, is it possible? This a common mistakes or unseen solution by many beginner’s in VB.Net try to make modification from their tables because they don’t have enough idea to work it. Fortunately, this is how…

Once you run the program, the database file and other object are in a folder name of your project. However, we do have two (2) database file saves on the separated folder. First, is in the Name of your Project Folder and the second one is in your Debug Folder


This is how it looks.
Database in Project folder name
Database in Project folder name
And other one.
Database in Debug folder
Database in Debug folder

Now, you have an idea where the database file was located. This is the magic trick if you want to make some modification on your table’s columns or whatever you want. Do NOT make any changes on your Debug Folder where the Database was located because whatever you made is nothing happen once the program’s start running (F5). If you want to try, open your database in Debug Folder, double click and right click on the table and click Datasheet View to show, and to add some entry or columns. Then close MS Access Database and to try run your program (F5). After run, stop the programming running and try to open again your Database in Debug folder to see what happen if there’s new added data. Nothing happen, right? The current data still unchanged.

Fortunately, if you want to do any modification in your table’s columns or entry, used first Database in the Project Folder Name not in the Debug folder. Try it to assure if it is working or not. Now, whatever changes happen you made in the first database table’s columns or entry is also automatically affected in the Debug folder Database.

The only difference, modification made from Debug folder Database nothing happens and still remain unchanged.

0 comments:

Post a Comment