473,395 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ado.net dataset and bindings

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
Nov 20 '05 #1
2 1031
Hello Mike
Sample code:

Dim MyEdit As New
UpdateAccountTypes(MyTable.Rows(Me.DataGrid1.Curre ntCell.RowNumber))

MyEdit.ShowDialog()

Me.DataGrid1.Refresh()

Explanationof Code:

UpdateAccountTypes is a form that takes a DataRow as an argument to the
New() contstuctor

I get the currently selected row of the datagrid using:

MyTable.Rows(Me.DataGrid1.CurrentCell.RowNumber)

This should give you some insight into doing what you need
Ibrahim

ib******@nospamdoiwant.malluf.com

"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

Nov 20 '05 #2
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

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom Gao | last post by:
Hello, We are having a recurring problem of a typed dataset that we have in a form dissapearing from the VS designer and all bindings being lost. The dataset is defined in another component and...
0
by: Neo | last post by:
I was wondering what is the "right" way to deal with datasets is. Particularly sharing DataSets between forms. Here is my situation. I have a simple Customer Database, that holds some information...
0
by: Tom Gao | last post by:
Hello, We are having a recurring problem of a typed dataset that we have in a form dissapearing from the VS designer and all bindings being lost. The dataset is defined in another component and...
3
by: Gary | last post by:
I have a DataSet where two tables have a relation (the parent / child relationship is also successfully added to the DataSet Relations collection). I am looking for a way to programmatically...
2
by: JohnR | last post by:
I have a table in a dataset whose fields are bound to various controls on my form. The records are sorted by primary key so when I use the currencymanager to navigate the data, it all appears...
0
by: Chris | last post by:
Hello, I have a problem with re-loading datasets. As a simple example, if I have an SQL table of addresses comprising active and inactive addresss, I wish to load either sub-set by clicking on...
3
by: Sheikko | last post by:
ADO.NET - Working with DataSet ========================= HI, I want to create an application that interact with a DB. I wont to use SQL statement, but I want to use DataSet. - I have created my...
8
by: shark | last post by:
Hi. I have DataGridView bound to my dataset through bindingsource component. My dataset is filled on separate thread. While this thread is working I receive "Cross-thread operation not valid"...
4
by: John Sheppard | last post by:
Hello there I was wondering if anyone could help me, I am trying to pass a typed dataset to a dialoged child form by reference. I have binding sources sitting on the child form. So to refresh...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.