The Data Adapter will use our connection (a well???) and pump info into our Data Set which will be our bucket.Like if we wanted to make sure that each name is properly capitalized we could do that before adding it to the list Box1. The last method here for selecting data is using a command object and fetching what is called a “Reader”.
positive and negative characteristics of dating - Updating the database with a dataadapter and the dataset
Once we have it in the bucket, we can use the data independent of the connection or adapter.
This example will use the Data Set to “bind” to the listbox and empty its contents into the listbox control. The only trick here is that we bind the database to the listbox and tell the listbox to use the name column as both the names we display to the user as well as the value each item has.
Just like you can give each option item in HTML select boxes a different value than its actual list item name.
The advantage of this method is that it is a quick “dump all the info here” method.
The first example will be to use a Data Adapter class and its fill method to load it into a Data Set.
Think of this method like using a hose to fill up a bucket.
We could reset the pointer, but then that would kill the speed here.
// Our command object which again uses the connection string and a connection object Ole Db Command cmd = new Ole Db Command("select name from employees", connection); // Our reader is going to fetch our results Ole Db Data Reader reader = cmd.
All we need is to tell it which driver to use and where to find the database file. Then we give it the connection string and open the connection…
If this had been a database like My SQL located on another server, we would have to specify IP address info as well as port. Notice in our code above we create a new Ole Db Connection and give it a connection string to tells it where to find and to use our OLEDB 4.0 driver.
So if we see “John” in the listbox, the value of that item will also be “John”.