S
Steve Manley
Hi there,
I need help
I wrote the code below to find a record specified by the
user. It only works if the fields being searched match
the sort criteria used to retreive the records from the
database. My problem is the users of the application
would like to to ability to perform searches using fields
of their own choosing.
It looks like the dataview (dvCustomer) is sorted and the
record is located in the dataview but this is not being
reflected in the dataset (dscustomer).
Can anyone give me sample code?
I don't need Datagrid control samples.
Thanks in advance for your help
Steve
=================Sample code below=====================
Private Sub btnFind_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnFind.Click
Dim strFirstName$
Dim strLastName$
Dim ArrayFind(1) As Object
Dim dvCustomer As DataView
Try
dvCustomer = New DataView(dsCustomers.Tables
("Customers"))
strFirstName = InputBox("Enter First Name to
find Customer record.", "Find Record", "John", 100, 100)
If Trim(strFirstName) <> "" Then
strLastName = InputBox("Enter Last Name to
find Customer record.", "Find Record", "Mark", 100, 100)
If Trim(strLastName) <> "" Then
ArrayFind(0) = strFirstName
ArrayFind(1) = strLastName
dvCustomer.Sort = "FirstName,LastName"
Dim intFind As Integer
intFind = dvCustomer.Find(ArrayFind)
If intFind <> -1 And intFind <=
Me.BindingContext(dsCustomers, "Customers").Count - 1 Then
Me.BindingContext
(dsCustomers, "Customers").Position = intFind
Else
MsgBox("Record not found.",
MsgBoxStyle.Exclamation, "Search Completed")
End If
Else
MessageBox.Show("Last Name is required
to do a search", "Last Name Missing",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Else
MessageBox.Show("First Name is required to
do a search", "First Name Missing", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End If
Catch
Err_Handler(Err.Number, Err.Description,
Me.Name, "btnFind_Click")
Finally
Err.Clear()
End Try
End Sub
I need help
I wrote the code below to find a record specified by the
user. It only works if the fields being searched match
the sort criteria used to retreive the records from the
database. My problem is the users of the application
would like to to ability to perform searches using fields
of their own choosing.
It looks like the dataview (dvCustomer) is sorted and the
record is located in the dataview but this is not being
reflected in the dataset (dscustomer).
Can anyone give me sample code?
I don't need Datagrid control samples.
Thanks in advance for your help
Steve
=================Sample code below=====================
Private Sub btnFind_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnFind.Click
Dim strFirstName$
Dim strLastName$
Dim ArrayFind(1) As Object
Dim dvCustomer As DataView
Try
dvCustomer = New DataView(dsCustomers.Tables
("Customers"))
strFirstName = InputBox("Enter First Name to
find Customer record.", "Find Record", "John", 100, 100)
If Trim(strFirstName) <> "" Then
strLastName = InputBox("Enter Last Name to
find Customer record.", "Find Record", "Mark", 100, 100)
If Trim(strLastName) <> "" Then
ArrayFind(0) = strFirstName
ArrayFind(1) = strLastName
dvCustomer.Sort = "FirstName,LastName"
Dim intFind As Integer
intFind = dvCustomer.Find(ArrayFind)
If intFind <> -1 And intFind <=
Me.BindingContext(dsCustomers, "Customers").Count - 1 Then
Me.BindingContext
(dsCustomers, "Customers").Position = intFind
Else
MsgBox("Record not found.",
MsgBoxStyle.Exclamation, "Search Completed")
End If
Else
MessageBox.Show("Last Name is required
to do a search", "Last Name Missing",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End If
Else
MessageBox.Show("First Name is required to
do a search", "First Name Missing", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation)
End If
Catch
Err_Handler(Err.Number, Err.Description,
Me.Name, "btnFind_Click")
Finally
Err.Clear()
End Try
End Sub