473,725 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1038
Hello Mike
Sample code:

Dim MyEdit As New
UpdateAccountTy pes(MyTable.Row s(Me.DataGrid1. CurrentCell.Row Number))

MyEdit.ShowDial og()

Me.DataGrid1.Re fresh()

Explanationof Code:

UpdateAccountTy pes 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.Curr entCell.RowNumb er)

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

ib******@nospam doiwant.malluf. com

"Mike" <an*******@disc ussions.microso ft.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;int egrated security=sspi;" )

Dim ocmd As New SqlCommand("sel ect * 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).C olumns("eventcd ")

ods.Tables(0).P rimaryKey = colpk

irow = ods.Tables(0).R ows.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*******@disc ussions.microso ft.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
1183
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 we reference that component, and use the dataset designer tool to simply create the dataset variable on the form. Every so often though, with no apparent pattern, we loose the dataset from the designer with the bindings. The variables are still
0
1788
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 about Customers including thier address. Lets call this Table "Customers". The Customers Table references another Table for Address information, for instance I have a table of "Zipcodes", Now I want an app with two forms, one form to browse my...
0
1050
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 we reference that component, and use the dataset designer tool to simply create the dataset variable on the form. Every so often though, with no apparent pattern, we loose the dataset from the designer with the bindings. The variables are still
3
1470
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 construct something analogous to a database view where the record (or row) would show table1.Field1, table1.field2, table2.Field2, etc. I tried using a DataView object, but this appears to allow only filtering and sorting.
2
7643
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 sorted. When I add a new row to this table and save it (using dataadapter.update) it appears at the end of the list no matter where it should fall in the sorted list. When I exit and re-enter the form the newly added record is then presented in the...
0
2024
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 a checkBox. The data is Bound to various controls on a Windows Form. This works fine, I can load either set of data into the same
3
4578
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 application - From SERVER EXPLORER panel, I have added a connection to a database (MyDB) and the name of the dataset is "MyDBDataSet" . - From DATA SOURCE panel, I have added Tables that I want to use (Setting).
8
2556
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" exception because bindingsource tries to update grid cells from another thread (invoke is required). How to handle such scenario ? Thanks
4
5927
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 them I just set their datasource. I am guessing this is probably what is causing the problem. Is there a better way to do this? Anyway this all works happily and things show up when the record already exists but I have 2 problems ; 1) When I add...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9113
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4519
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2635
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.