ASP.NET & Databases Part 3
page 4 of 5
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 19522/ 52

The CommandBuilder

OleDbCommandBuilder

I didn't cover this earlier because it wasn't relevant until now. The CommandBuilder builds SQL Statements for a specified DataAdapter. When dimensioning it (when will I use that word again?) you specify the name of the DataAdapter, when you call the Update() method of the DataAdapter, it checks the CommandBuilder for the SQL statements it needs to update the database.

The alternative is to set the individual commands in the DataAdapter (or use the OleDbCommand to do it), which is quite inflexible and I don't really see much of a point to it.

Other Stuff

There is other stuff that you can do with datasets, and you have already learnt it. I'll give you the code sample and you can decode it -

<%@ Page Language="VB" Debug="true" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Oledb" %>
<script language="VB" runat="server">
Sub Page_Load(sender as object, e as eventargs)

Dim objConn as New OleDBConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=e:\sff\site\db\test.mdb")
objConn.Open()

Dim ds as Dataset = New DataSet()
Dim objAdapter as New OleDbDataAdapter("SELECT * FROM users", objConn)
Dim objCmdBld as New OleDbCommandBuilder(objAdapter)

objAdapter.Fill(ds, "users")


Dim drow as DataRow

drow = ds.Tables("users").Rows(1)

drow(0) = "Joseph"

ds.Tables("users").Rows(0).AcceptChanges

objAdapter.Update(ds, "users")
objconn.Close()
End Sub
</script>

View Entire Article

User Comments

Title: ASP.NET & Databases : Part 3   
Name: ttt
Date: 2005-04-01 1:27:18 PM
Comment:
good

Product Spotlight
Product Spotlight 





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


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-09-20 4:38:34 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search