I have a routine in which I am attempting to loop through a text file using a StreamReader and import the data I mine from it to a SQL Server 2008 table called BSR. I can populate an entire dataset with no problems (checked the dataset contents in debug mode and all is well) but it will not update to SQL Server no matter what I try.
The dataset (ds) is of type dsBSR, which is a drag-and-drop from Server Explorer of the table BSR. This is my first attempt at typed datasets and so far I am failing miserably. The code is pasted below, and all it needs to do is add newly imported lines (which are in a table in the dataset) to the table in SQL Server. Thanks in advance for your assistance!
Dim da As New SqlDataAdapter("SELECT * FROM BSR", con)
Dim con As New SqlConnection(My.Settings.BSROnSQLServer)
Dim ds As New dsBSR
Dim row As dsBSR.BSRRow
If con.State = ConnectionState.Closed Then
'Code to populate dataset is in this range
da.FillSchema(ds, SchemaType.Mapped, "BSR")
Dim cb As New SqlCommandBuilder(da)
da.InsertCommand = cb.GetInsertCommand
da.UpdateCommand = cb.GetUpdateCommand
MessageBox.Show(da.Update(ds, "BSR") & " records imported.", "Import results")
Catch dbex As SqlException
MessageBox.Show("Error: " & dbex.ToString)