ASP.NET & Databases Part 1
page 5 of 7
by . .
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 33692/ 102

Data Adapter

Data Adapter

The OleDbDataAdapter is the thing that takes your data and provides an interface between the data and the dataset. You create it like all of the others -

Dim objAdapter as New OleDbDataAdapter("SELECT * FROM users", objConn)

Seems like the OleDbCommand but its not. You can use this Data Adapter for things like Filling a dataset, Updating the data source with data from the dataset and using SQL commands on the dataset. I'll take you through some of these now.

Dim ds as Dataset = New DataSet()
objAdapter.Fill(ds, "users")

This method (fill) takes in the name of the dataset and the table in the dataset to put it into. The table is created if it doesn't exist and then populates it with the data that it got from the database using the query it sent.


Mapping allows you to create an alias for the names of columns in the dataset. The names don't affect the data source and when sending through the DataAdapter are automatically converted.

objAdapter.TableMappings.Add("adbtable", "users")
With objAdapter.TableMappings(0).ColumnMappings
     .Add("PID", "ID")
     .Add("LastName", "LName")
     .Add("StreetAddress", "Addy")
End With

Now when you call the dataset you don't have to use



You can use


When we talk about datasets in Part 2, you'll see how this can come in useful sometimes.

View Entire Article

User Comments

Title: Re: One comment   
Name: Philip Q
Date: 2004-10-25 11:08:14 PM

The reason for that is that you have imported System.Data, but not System.Data.OleDb into your page.
Title: One comment.   
Name: Jen
Date: 2004-10-25 9:33:47 AM
Putting the OleDBConnection command into the page_load event gives the error that OleDBConnection is not defined. However, OleDb.OleDbConnection works.
Title: to work with more than one dataset   
Name: Santhosh Kumar A.
Date: 2004-10-19 6:41:29 AM
I found it very good. Please try to include how
to manipulate rows using For Each ... Next loop.
I was really searching for it.

Santhosh Kumar A.
Kerala, India

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2021  |  Page Processed at 2021-12-08 2:24:37 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search