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

The CommandBuilder


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")

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"


objAdapter.Update(ds, "users")
End Sub

View Entire Article

User Comments

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

Product Spotlight
Product Spotlight 

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

©Copyright 1998-2020  |  Page Processed at 2020-02-21 8:09:36 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search