View Single Post
  #5 (permalink)  
Old 07-10-2007, 10:00 AM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
load up visual studio, and add a folder called "App_Code" in the root of your website. Then right click on your app_code folder and click ADD. Add a Dataset and name it DataLayer. This is a GUI for creating data tables and queries. From here you can create a connectionstring (it will ask you right away) and will store it in the Web.Config file. Then you can create table Adapters that you can use later on. If you have a 'User' table in your database, then add a User Table adapter... then you can add queries like GetAllUsers or GetUserByUserID or GetUserByEmail, etc... all in the Table Adapter 'User'.

Then in your page code, you can bind your controls directly to the Table Adapters You can say...

Code:
Using UserAdapter as New DataLayer.UserTableAdapter
     Using UserTable as New DataLayer.UserTable = UserAdapter.GetAllUsers()
         DropDownListControl.DataSource = UserTable
         DropDownListControl.DataBind()
     End Using
End Using
- by using the using, it does the try catch, and dispose of the objects for you... it fills a datatable called UserTable from the UserAdapter's Query GetAllUsers... Have fun... this is pretty addictive once you get used to it
Reply With Quote