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