Hi Mike,
Pass the primary key as a global variable by developing a globals class in a
module. Then search using the PK in a standard way. Below is an example of
using a PK to search a dataset/datatable:
Dim oconn As New SqlConnection("data source=d5z0071;initial
catalog=imc;integrated security=sspi;")
Dim ocmd As New SqlCommand("select * from evcodes", oconn)
Dim oda As New SqlDataAdapter(ocmd)
Dim ods As New DataSet("Event Codes")
Try
oconn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
oda.Fill(ods, "Event Codes")
Dim irow As DataRow
Dim colpk(0) As DataColumn
colpk(0) = ods.Tables(0).Columns("eventcd")
ods.Tables(0).PrimaryKey = colpk
irow = ods.Tables(0).Rows.Find("02") ' Mike - in this table the pk is a 2
char string column as I have
' need for only a few different kinds of events
If irow Is Nothing Then
MessageBox.Show("Not found")
Else
MessageBox.Show(irow("descrip"))
End If
oconn.Close()
You can also use a dataview to search when searching for non-PK cols.
HTH,
Bernie Yaeger
"Mike" <an*******@discussions.microsoft.com> wrote in message
news:01****************************@phx.gbl...
I double click and item in a list box on a form that
contains the primary index value for a dataset. this
brings up a second form to display the row fields of the
dataset through databindings
The primary index value is made available to the second
form.
How do i make the second form display the row that
contains the primary index instead of the first row in
the dataset?
I've been unsuccessful in trying to pass the row value
or position of the dataset to the second form.
Any help would be appreciated.
thanks mike