Results 1 to 3 of 3

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

  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.

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: Jumps to exception after DA.FILL(DS) why?

    What is the error message?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2007
    Posts
    166

    Re: Jumps to exception after DA.FILL(DS) why?

    yeah the error message would have been useful first time round sorry.

    It says that no value given for one or more required required parameter.

    I have checked my sql statement and all seems correct. All fields are added to the where clause except for the ID which is what i am trying to achieve.

    The sql statement that is being used is

    vb Code:
    1. ' retrieve client ID
    2.         Dim sqlcliret As String
    3.         sqlcliret = "Select client_id from tbl_client where " & _
    4.         "First_Name = '" & Me.txt_clifirstname.Text & "' AND Surname ='" & _
    5.         Me.txt_clisurname.Text & "' AND Address_Line1 = '" & _
    6.         Me.txt_cliaddress1.Text & "' AND Address_Line2 =  '" & _
    7.         Me.txt_cliaddress2.Text & "' AND Address_Line3 =  '" & _
    8.         Me.txt_cliaddress3.Text & "' AND County = '" & _
    9.         Me.txt_clicounty.Text & "' AND Postcode = '" & _
    10.         Me.txt_clipostcode.Text & "' AND Telephone_Number = " & _
    11.         Me.txt_cliteleno.Text & " AND Mobile_Number =  " & _
    12.         Me.txt_climobno.Text & " AND Email_Address = '" & _
    13.         Me.txt_cliemail.Text & "' AND Preferred_Contact_Method = '" & _
    14.         Me.txt_cliprefcon.Text & "'
    "

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