|
-
May 1st, 2007, 06:16 PM
#1
Thread Starter
Addicted Member
[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:
If Me.cmb_client.Visible = True Then
client = Me.cmb_client.SelectedValue
Else
' INSERT into the client table for new record
Conn.Open()
Comm = New System.Data.OleDb.OleDbCommand(SQL1, Conn)
MessageBox.Show(SQL1)
Comm.ExecuteNonQuery()
Comm.Dispose()
'retrieve client id
Comm = New System.Data.OleDb.OleDbCommand(sqlcliret, Conn)
'defines new data adapter
Dim DA As New System.Data.OleDb.OleDbDataAdapter
DA.SelectCommand = Comm
' defines new dataset
Dim DS As New DataSet
Try
DA.Fill(DS)
DT = DS.Tables(0)
Catch ex As Exception
'The user may have entered a string as their login id
MessageBox.Show(Err.Description)
Me.Close()
Exit Sub
End Try
Comm.Dispose()
DA.Dispose()
'if the number of rows returned = 0 displays message to the user
If DT.Rows.Count = 0 Then
MessageBox.Show("No records match your search" & vbNewLine & "Please try different criteria", "Search Results", MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
Exit Sub
Else
RecordNo = 0
suspectID = DT.Rows(RecordNo).Item("Suspect_Name").ToString
MessageBox.Show(suspectID)
End If
'set client id
'client = new value
End If
Last edited by HelpLaura; May 3rd, 2007 at 10:35 AM.
-
May 1st, 2007, 06:25 PM
#2
Re: Jumps to exception after DA.FILL(DS) why?
What is the error message?
-
May 1st, 2007, 06:30 PM
#3
Thread Starter
Addicted Member
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:
' retrieve client ID
Dim sqlcliret As String
sqlcliret = "Select client_id from tbl_client where " & _
"First_Name = '" & Me.txt_clifirstname.Text & "' AND Surname ='" & _
Me.txt_clisurname.Text & "' AND Address_Line1 = '" & _
Me.txt_cliaddress1.Text & "' AND Address_Line2 = '" & _
Me.txt_cliaddress2.Text & "' AND Address_Line3 = '" & _
Me.txt_cliaddress3.Text & "' AND County = '" & _
Me.txt_clicounty.Text & "' AND Postcode = '" & _
Me.txt_clipostcode.Text & "' AND Telephone_Number = " & _
Me.txt_cliteleno.Text & " AND Mobile_Number = " & _
Me.txt_climobno.Text & " AND Email_Address = '" & _
Me.txt_cliemail.Text & "' AND Preferred_Contact_Method = '" & _
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|