J
james
Hi, I am using the following code to find a particular client in a database
table and if the record exists
display the data in one of the rows in a textbox. It works just fine as
long as the actual record (in this case CLIENTID) exists, it will then show
the test in the cell that I want in a textbox.
BUT, if the record does not exist, i get an Out of Range Error. How can I
check in my SQL statement if the CLIENTID does not exist to exit the
routine?
' client is from another table and is used to find the additional data I am
looking for
Dim Noteonn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User
ID=Admin;Data Source=" & mypath() & "\Data\BONDNOTE.mdb;Mode=ReadWrite")
Noteonn.Open()
Notesql = New OleDbCommand("SELECT * FROM Record WHERE [CLIENTID]='" &
client & "'", Noteonn)
Dim Noteda As New OleDbDataAdapter(Notesql)
Dim Noteds As New DataSet("Record")
Noteda.Fill(Noteds, "Record")
DataGrid1.SetDataBinding(Noteds, "Record")
Dim colcount As Integer
txtNote.Text = DataGrid1.Item(0, 5)
Noteonn.Close()
Any suggestons would be appreciated.
james
table and if the record exists
display the data in one of the rows in a textbox. It works just fine as
long as the actual record (in this case CLIENTID) exists, it will then show
the test in the cell that I want in a textbox.
BUT, if the record does not exist, i get an Out of Range Error. How can I
check in my SQL statement if the CLIENTID does not exist to exit the
routine?
' client is from another table and is used to find the additional data I am
looking for
Dim Noteonn As New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User
ID=Admin;Data Source=" & mypath() & "\Data\BONDNOTE.mdb;Mode=ReadWrite")
Noteonn.Open()
Notesql = New OleDbCommand("SELECT * FROM Record WHERE [CLIENTID]='" &
client & "'", Noteonn)
Dim Noteda As New OleDbDataAdapter(Notesql)
Dim Noteds As New DataSet("Record")
Noteda.Fill(Noteds, "Record")
DataGrid1.SetDataBinding(Noteds, "Record")
Dim colcount As Integer
txtNote.Text = DataGrid1.Item(0, 5)
Noteonn.Close()
Any suggestons would be appreciated.
james