ccrookston
2/1/2008 2:49:00 AM
Ok, ignore my previous reply.
After reading up on DataAdapters in Sam's Asp.Net 2.0 Unleashed, this is the
code with which I am now working:
~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Create connection to the flat file
Dim TextConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & "C:\Inetpub\wwwroot\GrandCentralCoupons\comissionjunction\"
& ";" & _
"Extended Properties=""Text;HDR=Yes;FMT=Delimited;"""
' Load data from flat file into a DataTable
Dim TextConn As New System.Data.OleDb.OleDbConnection(TextConnectionString)
Dim dad1 As New System.Data.OleDb.OleDbDataAdapter("Select top 5 * from
cj.txt", TextConn)
Dim dtblSource As DataTable = New DataTable
dad1.Fill(dtblSource)
' Verify that the data is corect by binding to a gridview for visual display
GridView1.DataSource = dtblSource
GridView1.DataBind()
' Now, get the current data from the destination database table
Dim dbConn As New
SqlConnection(WebConfigurationManager.ConnectionStrings("GCC_Remote").ConnectionString)
Dim dad2 As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM
import_temp_cj2", dbConn)
'Create update, insert, and delete commands
Dim builder As New SqlCommandBuilder(dad2)
' Add new data to a second datatable
Dim dtblDestination As DataTable = New DataTable
dad2.Fill(dtblDestination)
' verify the data is correct by binding to a second gridview for display
GridView2.DataSource = dtblDestination
GridView2.DataBind()
' mix. mingle, manage the data form the two datasets
' /* code removed for easy of reading */
' verify the new data is correct by binding to a third gridview for display
GridView3.DataSource = dtblDestination
GridView3.DataBind()
' Update the database table with new data
dad2.UpdateBatchSize = 0
Dim numUpdates As Integer = dad2.Update(dtblDestination)
label1.Text = "Rows updated: " & numUpdates.ToString
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Still, NOTHING!!!! The label always says "Rows updated: 0" and the data in
the db remains unchanged.
I have been over the example in the book again and again, and it looks like
I am doing everything by the book, and yet it does not work.
Arrrgggg!!!! What am I doing wrong!!!
Please... somebody put me out of my misery.
Casey