PC Review


Reply
Thread Tools Rate Thread

ado.net dataset and bindings

 
 
Mike
Guest
Posts: n/a
 
      7th Dec 2003
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
 
Reply With Quote
 
 
 
 
IbrahimMalluf
Guest
Posts: n/a
 
      8th Dec 2003
Hello Mike


Sample code:

Dim MyEdit As New
UpdateAccountTypes(MyTable.Rows(Me.DataGrid1.CurrentCell.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

(E-Mail Removed)



"Mike" <(E-Mail Removed)> wrote in message
news:01a401c3bd0d$bd3334a0$(E-Mail Removed)...
> 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



 
Reply With Quote
 
Bernie Yaeger
Guest
Posts: n/a
 
      8th Dec 2003
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" <(E-Mail Removed)> wrote in message
news:01a401c3bd0d$bd3334a0$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset Data bindings Best practices? Neo Microsoft Dot NET 0 29th Apr 2005 09:34 PM
Typed dataset, bindings and endCurrentEdit =?Utf-8?B?bm9ybWRAb25saW5lLmtub3JyYXNzb2NpYXRlcy5j Microsoft Dot NET Framework Forms 1 24th Jan 2005 03:31 PM
Typed dataset, bindings and endCurrentEdit =?Utf-8?B?bm9ybWRAb25saW5lLmtub3JyYXNzb2NpYXRlcy5j Microsoft ADO .NET 0 10th Dec 2004 02:01 PM
Datagrid/Dataset bindings Rick Microsoft VB .NET 2 31st Oct 2003 05:28 PM
Dataset and Bindings dave@here.ca Microsoft ADO .NET 3 17th Sep 2003 12:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:32 AM.