Results 1 to 3 of 3

Thread: [RESOLVED]Jumps to exception after DA.FILL(DS) why?

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    166

    [RESOLVED]Jumps to exception after DA.FILL(DS) why?

    I have the code below, and when it gets to the DT = DS.Tables(0) after the DA.Fill(DS) it jumps into the exception. Can anyone tell me why this is happening?

    What i am trying to do is retrive the ID assigned to the record that has been inserted by SQL1
    I have checked, and the records are being inserted into the database as well

    vb Code:
    1. If Me.cmb_client.Visible = True Then
    2.             client = Me.cmb_client.SelectedValue
    3.         Else
    4.             ' INSERT into the client table for new record
    5.             Conn.Open()
    6.             Comm = New System.Data.OleDb.OleDbCommand(SQL1, Conn)
    7.             MessageBox.Show(SQL1)
    8.             Comm.ExecuteNonQuery()
    9.             Comm.Dispose()
    10.  
    11.             'retrieve client id
    12.             Comm = New System.Data.OleDb.OleDbCommand(sqlcliret, Conn)
    13.  
    14.             'defines new data adapter
    15.             Dim DA As New System.Data.OleDb.OleDbDataAdapter
    16.             DA.SelectCommand = Comm
    17.  
    18.             ' defines new dataset
    19.             Dim DS As New DataSet
    20.  
    21.             Try
    22.                 DA.Fill(DS)
    23.                 DT = DS.Tables(0)
    24.             Catch ex As Exception
    25.                 'The user may have entered a string as their login id
    26.                 MessageBox.Show(Err.Description)
    27.                 Me.Close()
    28.  
    29.                 Exit Sub
    30.             End Try
    31.  
    32.             Comm.Dispose()
    33.             DA.Dispose()
    34.  
    35.             'if the number of rows returned  = 0 displays message to the user
    36.             If DT.Rows.Count = 0 Then
    37.                 MessageBox.Show("No records match your search" & vbNewLine & "Please try different criteria", "Search Results", MessageBoxButtons.OK, MessageBoxIcon.Information)
    38.                 Me.Close()
    39.  
    40.                 Exit Sub
    41.             Else
    42.                 RecordNo = 0
    43.                 suspectID = DT.Rows(RecordNo).Item("Suspect_Name").ToString
    44.                 MessageBox.Show(suspectID)
    45.             End If
    46.  
    47.             'set client id
    48.             'client = new value
    49.  
    50.         End If
    Last edited by HelpLaura; May 3rd, 2007 at 10:35 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width