Ok, I'm back. I have a program that half works. It has a connection to an Access database with 2 data adapters. Each data adapter fills a dataset. I then dim a datatable from each dataset. I'll post the code and then explain what the problem is. Here is the code:
VB Code:
  1. Private Sub btnLoadParcels_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadParcels.Click
  2.         Dim reccount, whereiam, whereiam2, count2, addcount As Integer
  3.         Dim textline, formfield, adddisp As String
  4.         Dim tempdate As DateTime
  5.         Dim firsttime, foundparcel, foundowner As Boolean
  6.         firsttime = True
  7.         Dim dsparcel As New DataSet()
  8.         Dim dsparcelowner As New DataSet()
  9.         DaParcel.Fill(dsparcel)
  10.         DaParcelOwner.Fill(dsparcelowner)
  11.         Dim dtparcel As DataTable = dsparcel.Tables(0)
  12.         Dim dtparcelowner As DataTable = dsparcelowner.Tables(0)
  13.         FileOpen(1, "\\INFORMIX\GISDATA\cnci.txt", OpenMode.Binary, OpenAccess.Read, OpenShare.Shared)
  14.         While Not EOF(1)
  15.             count2 = count2 + 1
  16.             textline = LineInput(1)
  17.             Dim fieldarray() As String = textline.Split("|")
  18.             If firsttime = True Then
  19.             Else
  20.                 reccount = 0
  21.                 formfield = fieldarray(1)
  22.                 formfield = Mid(formfield, 1, 2) + "." + Mid(formfield, 3, 2) + "." + Mid(formfield, 5, 3) + "." + Mid(formfield, 8, 3)
  23.                 Do Until (reccount = dtparcel.Rows.Count)
  24.                     If dtparcel.Rows(reccount).Item("parcel-number") = formfield Then
  25.                         foundparcel = True
  26.                         whereiam = reccount
  27.                         reccount = dtparcel.Rows.Count - 1
  28.                     Else
  29.                         foundparcel = False
  30.                     End If
  31.                     reccount = reccount + 1
  32.                 Loop
  33.                 reccount = 0
  34.                 Do Until (reccount = dtparcelowner.Rows.Count)
  35.                     If dtparcelowner.Rows(reccount).Item("parcel_no") = formfield Then
  36.                         foundowner = True
  37.                         whereiam2 = reccount
  38.                         reccount = dtparcelowner.Rows.Count - 1
  39.                     Else
  40.                         foundowner = False
  41.                     End If
  42.                     reccount = reccount + 1
  43.                 Loop
  44.                 If foundparcel = True And foundowner = True Then
  45.                     dtparcelowner.Rows(whereiam2).Item("owner-name") = fieldarray(2)
  46.                     dtparcelowner.Rows(whereiam2).Item("owner-addr1") = fieldarray(3)
  47.                     dtparcelowner.Rows(whereiam2).Item("owner-addr2") = fieldarray(4)
  48.                     dtparcelowner.Rows(whereiam2).Item("owner-addr3") = fieldarray(5)
  49.                     dtparcelowner.Rows(whereiam2).Item("owner-zip5") = fieldarray(6)
  50.                     dtparcelowner.Rows(whereiam2).Item("owner-zip4") = fieldarray(7)
  51.                     dtparcelowner.Rows(whereiam2).Item("township") = fieldarray(0)
  52.                     dtparcel.Rows(whereiam).Item("addr-number") = fieldarray(8)
  53.                     dtparcel.Rows(whereiam).Item("addr-street") = fieldarray(9)
  54.                     dtparcel.Rows(whereiam).Item("parcel-lgl-desc") = fieldarray(18) + " " + fieldarray(19) + " " + fieldarray(20) + " " + fieldarray(21)
  55.                     dtparcel.Rows(whereiam).Item("parcel-township") = fieldarray(0)
  56.                     dtparcel.Rows(whereiam).Item("parcel-status") = fieldarray(25)
  57.                     If fieldarray(24) = "" Then
  58.                         tempdate = #1/1/1000#
  59.                     Else
  60.                         tempdate = CDate(fieldarray(24))
  61.                     End If
  62.                     dtparcel.Rows(whereiam).Item("update-date") = tempdate
  63.                     Try
  64.                         DaParcel.Update(dtparcel)
  65.                         DaParcelOwner.Update(dtparcelowner)
  66.                     Catch ex As DBConcurrencyException
  67.                     End Try
  68.                 ElseIf foundparcel = True And foundowner = False Then
  69.                 ElseIf foundparcel = False And foundowner = True Then
  70.                 ElseIf foundparcel = False And foundowner = False Then
  71.                     Dim newrow As DataRow = dtparcelowner.NewRow
  72.                     newrow("parcel_no") = formfield
  73.                     newrow("owner-name") = fieldarray(2)
  74.                     newrow("owner-addr1") = fieldarray(3)
  75.                     newrow("owner-addr2") = fieldarray(4)
  76.                     newrow("owner-addr3") = fieldarray(5)
  77.                     newrow("owner-zip5") = fieldarray(6)
  78.                     newrow("owner-zip4") = fieldarray(7)
  79.                     newrow("township") = fieldarray(0)
  80.                     dtparcelowner.Rows.Add(newrow)
  81.                     dtparcelowner.AcceptChanges()
  82.                     Dim newrow2 As DataRow = dtparcel.NewRow
  83.                     newrow2("addr-number") = fieldarray(8)
  84.                     newrow2("addr-street") = fieldarray(9)
  85.                     newrow2("parcel-lgl-desc") = fieldarray(18) + " " + fieldarray(19) + " " + fieldarray(20) + " " + fieldarray(21)
  86.                     newrow2("parcel-number") = fieldarray(1)
  87.                     newrow2("parcel-township") = fieldarray(0)
  88.                     newrow2("parcel-status") = fieldarray(25)
  89.                     If fieldarray(24) = "" Then
  90.                         tempdate = #1/1/1000#
  91.                     Else
  92.                         tempdate = CDate(fieldarray(24))
  93.                     End If
  94.                     newrow2("update-date") = tempdate
  95.                     dtparcel.Rows.Add(newrow2)
  96.                     DaParcel.Update(dsparcel)
  97.                     DaParcelOwner.Update(dsparcelowner)
  98.                     addcount = addcount + 1
  99.                 End If
  100.             End If
  101.             firsttime = False
  102.             txtNumber.Text = count2
  103.             txtNumber.Refresh()
  104.         End While
  105.         FileClose(1)
  106.         MsgBox("Done", MsgBoxStyle.OKOnly, "Message")
  107.         adddisp = addcount & " parcel records added."
  108.         MsgBox(adddisp, MsgBoxStyle.OKOnly, "Added Count")
  109.     End Sub
I have 2 problems:
1. The first condition, where foundparcel and foundowner are true does not happen. It goes thorough the loop as it should but it does not update the database at all.
2. The last condition, where foundparcel and foundowner are false partly happens. It does add some of the records but my add count is like 2500 and the database only shows about 300 more records? Help!

Thanks...

shootsnlad

PS: Yes, edneeis, this will look familiar to you. (It's almost done!)