Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

Load and Search MySQL Data Using VB.NET 2005 in Windows Applications

Added 31 Jul 2008

MySQL Data Load Using DataGridView Control

I have received a lot of questions from many VB.NET developers around the world about how to load MySQL data into the DataGridView Windows control. These questions have been sent to me by e-mail ([email protected]) or have been posted at www.vbmysql.com website forum. In fact, I would like to invite you to register and participate in our discuss forum. At this time, I’m in charge of keeping this website alive and responding all your MySQL/VB (VB 6.0 and VB.NET 2005) related questions. In general all of the developers knew how to load the data by using the DataSet or DataView ADO.NET objects. Most of the questions were about the DataGridView format and data search after the grid was loaded. For some reason(s) all of them were using dynamic SQL instead of stored procedures or functions. It’s very hard for me to believe that we still have developers up there doing dynamic (embedding) or/and parameterized SQL programming in their applications after MySQL AB Corporation released MySQL server version 5.0 with stored procedures, functions, triggers and views database objects development. I have made the decision to use stored procedures in this article to show them how easy is to develop and call them in VB.NET 2005. I developed these stored procedures using Toad for MySQL Freeware 3.0.0 freeware version from Quest Software, Inc. In my experience, Toad for MySQL is a powerful database management tool used to design and develop MySQL database objects like stored procedures, functions, triggers and views. In my previous article “MySQL Data Loading with Lookup Tables”, I show how to execute stored procedures in MySQL 5.0/VB.NET 2005 environment. Feel free to read the article and download the source code to apply in your real production applications.

In Windows database applications the data gets loaded in the load event of the form. Just in case, you need to be careful when to use this event to load the data as you don’t want to load a lot of data that it may slow down your form. I created a simple solution project in VB.NET 2005 with a form represented in Figure 1. This form named SearchForm contains a DataGridView with the contact info and a Contact Name TextBox entry to search for it.