473,395 Members | 2,783 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.

Refer to TableAdapter data in code?

I'm wanting to find the value of TableID on the current record displayed on
my form. I cannot seem to find any method within the TableAdapter class to
find this. An example I've found MS uses a bound control on the form and
then refers to the forms .text property. TableID is not displayed on the
form nor do I want it to be, so it does not have a bound control.

I've also ready that every TableAdapter has an associated DataTable class
which is actually what is populated with the data. Unfortunately I have not
been able to find a property in either class to find the value of a single
field in the current record.

Thanks,
Ryan
Jun 15 '06 #1
7 2328
Hi Ryan,

Thank you for posting.

Is the DataID a field in your DataTable?

You can get the value of any field in a datarow in a DataTable by using the
Rows collection of the DataTable. Suppose there's a DataTable named
"ClassesTable1" with two fields "ClassID" and "ClassName" in it. Then we
can get the values of the two fields in the second datarow by the following
statements:

dim var1 as Integer = ClassesTable1.Rows(1)("ClassID")
dim var2 as String = ClassesTable1.Rows(1)("ClassName")

If you have anything unclear, don't hesitate to get in touch. I look
forward to your reply.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 16 '06 #2
Hi Linda,

Yes DataID is a field in the DataTable. I'm trying to refer to the
DataTable associated with a DataSet that is used to bind controls on my
form. So I would assume the syntax would be as such:

Me.myDataSet.myDataTable.Rows(<<what do I put here>>)("DataID")

What do I put to get the current record displayed on the form (the row)?

Thanks,
Ryan

"Linda Liu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:3q**************@TK2MSFTNGXA01.phx.gbl...
Hi Ryan,

Thank you for posting.

Is the DataID a field in your DataTable?

You can get the value of any field in a datarow in a DataTable by using
the
Rows collection of the DataTable. Suppose there's a DataTable named
"ClassesTable1" with two fields "ClassID" and "ClassName" in it. Then we
can get the values of the two fields in the second datarow by the
following
statements:

dim var1 as Integer = ClassesTable1.Rows(1)("ClassID")
dim var2 as String = ClassesTable1.Rows(1)("ClassName")

If you have anything unclear, don't hesitate to get in touch. I look
forward to your reply.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 16 '06 #3
Well only took nearly a day to stumble across this, but here's how you do
it:
To refer to a field in the row of data currently on your form (for example
if you want to see DataID, but DataID is not bound to any form control):

Me.myDataSet.myTable.Rows(Me.myBindingSource.Posit ion)("DataID")

Whew!

"Ryan" <Ty****@newsgroups.nospam> wrote in message
news:uK**************@TK2MSFTNGP04.phx.gbl...
Hi Linda,

Yes DataID is a field in the DataTable. I'm trying to refer to the
DataTable associated with a DataSet that is used to bind controls on my
form. So I would assume the syntax would be as such:

Me.myDataSet.myDataTable.Rows(<<what do I put here>>)("DataID")

What do I put to get the current record displayed on the form (the row)?

Thanks,
Ryan

"Linda Liu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:3q**************@TK2MSFTNGXA01.phx.gbl...
Hi Ryan,

Thank you for posting.

Is the DataID a field in your DataTable?

You can get the value of any field in a datarow in a DataTable by using
the
Rows collection of the DataTable. Suppose there's a DataTable named
"ClassesTable1" with two fields "ClassID" and "ClassName" in it. Then we
can get the values of the two fields in the second datarow by the
following
statements:

dim var1 as Integer = ClassesTable1.Rows(1)("ClassID")
dim var2 as String = ClassesTable1.Rows(1)("ClassName")

If you have anything unclear, don't hesitate to get in touch. I look
forward to your reply.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==


Jun 16 '06 #4
Oh and the title of these posts are probably misleading. The TableAdapter
doesn't actually hold any data, it's just a nice tool for transferring data
back and forth from an actual database to a DataSet object. It's taken me
awile to figure out just how .NET 2.0 works.

"Ryan" <Ty****@newsgroups.nospam> wrote in message
news:em**************@TK2MSFTNGP05.phx.gbl...
Well only took nearly a day to stumble across this, but here's how you do
it:
To refer to a field in the row of data currently on your form (for example
if you want to see DataID, but DataID is not bound to any form control):

Me.myDataSet.myTable.Rows(Me.myBindingSource.Posit ion)("DataID")

Whew!

"Ryan" <Ty****@newsgroups.nospam> wrote in message
news:uK**************@TK2MSFTNGP04.phx.gbl...
Hi Linda,

Yes DataID is a field in the DataTable. I'm trying to refer to the
DataTable associated with a DataSet that is used to bind controls on my
form. So I would assume the syntax would be as such:

Me.myDataSet.myDataTable.Rows(<<what do I put here>>)("DataID")

What do I put to get the current record displayed on the form (the row)?

Thanks,
Ryan

"Linda Liu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:3q**************@TK2MSFTNGXA01.phx.gbl...
Hi Ryan,

Thank you for posting.

Is the DataID a field in your DataTable?

You can get the value of any field in a datarow in a DataTable by using
the
Rows collection of the DataTable. Suppose there's a DataTable named
"ClassesTable1" with two fields "ClassID" and "ClassName" in it. Then we
can get the values of the two fields in the second datarow by the
following
statements:

dim var1 as Integer = ClassesTable1.Rows(1)("ClassID")
dim var2 as String = ClassesTable1.Rows(1)("ClassName")

If you have anything unclear, don't hesitate to get in touch. I look
forward to your reply.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==



Jun 16 '06 #5
Hi Ryan,

Thanks for your response.

Yes, you could use the Position property of the myBindingSource to get the
position of the current datarow. You could also use the Current property of
the myBindingSource to get the current datarow directly.

For example, the statement
"((DataRowView)Me.myBindingSource.Current)("DataID ") " is equal to the
statement
"Me.myDataSet.myTable.Rows(Me.myBindingSource.Posi tion)("DataID")".

If you have any other questions, please do not hesitate to contact us. It
is always our pleasure to be of assistance.

Have a nice day!
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 19 '06 #6
Thanks Linda,

I was wondering about the .current property. Actually I was having some
buggy behavior with my code and once I replaced it with yours it now works
properly.

Ryan

"Linda Liu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:Px**************@TK2MSFTNGXA01.phx.gbl...
Hi Ryan,

Thanks for your response.

Yes, you could use the Position property of the myBindingSource to get the
position of the current datarow. You could also use the Current property
of
the myBindingSource to get the current datarow directly.

For example, the statement
"((DataRowView)Me.myBindingSource.Current)("DataID ") " is equal to the
statement
"Me.myDataSet.myTable.Rows(Me.myBindingSource.Posi tion)("DataID")".

If you have any other questions, please do not hesitate to contact us. It
is always our pleasure to be of assistance.

Have a nice day!
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 19 '06 #7
Hi Ryan,

Thank you for your response.

The Current property of the myBindingSource gets the current item in the
list. The type of the value of this property is object. To use this value,
you should cast it to a properly type. In this case, the type of the items
in the myBindingSource is DataRowView. So you should cast the value to the
type of DataRowView.

If you have any other questions, please don't hesitate to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

================================================== ==
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
================================================== ==

Jun 20 '06 #8

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

Similar topics

1
by: RobZ via DotNetMonster.com | last post by:
Hi all, I am using a tableadapter to read data from a table - no problem, I have configured the Tableadapter to add an InsertQuery. My problem is when I first Call the InsertQuery and then...
0
by: dbuchanan | last post by:
Hello, I have added a query to my TableAdapter that accepts a parameter (The ID) to filter the data. It will return only one record. I tested it in the designer and it returns one record as...
9
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
3
by: Mike | last post by:
Dear Group, When I add a DataTable to a Typed Dataset, and a TableAdapter to the DataTable, I am able to create methods to send updates directly to the database (GenerateDBDirectMethods),...
15
by: philip | last post by:
On a form, I have a datagridview. This datagridview is constructed on a dataset filled by a tableadapter. The table adapter do very well what it must do when filling dataset. Insertions,...
1
by: Demetri | last post by:
I have a question / concern regarding the new suggested way of creating a data access layer in an n-tier application. Typically, a web application specifically, using the SOA (Service Oriented...
2
by: googlegroups.dsbl | last post by:
I'm really confused here, and am wondering if someone knows what could be the issue with my TableAdapter query. A few months ago, I created a really neat program that has th ability to search by...
3
by: =?Utf-8?B?UmljaCBIdXRjaGlucw==?= | last post by:
I'm not really sure how to ask this question because I'm still getting my feet wet with data access and VB.NET, but here goes: To start off with, I'm using VB 2005 Express to connect to an Access...
8
by: Boris227 | last post by:
I have written an application that has a DataGridView for users to amend a table. When finished they click a 'Save' button, which generates a series of queries based on the new data. The problem...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...

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.