OK, so, after a day of poking around for different ways to ask this question
and looking for answers in dozens of places, I finally found one site that
got me on the right track. Do I remember it? No, and the URL is on my work PC
so all I have to offer is my solution.
In the class where I wanted to make my programming decision, I created an
instance of the DataTable object and an instance of the DataRowCollection
object:
Protected dt As DataTable
Protected dr As DataRowCollection
Then I grabbed the table I wanted then its row collection:
Me.dt = ProductsDataSet.Tables("N_Options") 'The table I want
Me.dr = dt.Rows() 'The table's row collection
Once I had the collection of rows in the table (because of the nature of the
query, I know it _should_ only be a single row), I was able to get the value
of the column I was interested in:
Dim myOType As String
myOType = Me.dr.Item(0).Item("O_Type").ToString()
Now that I have myOType, I can make whatever programming decisions need to
be made.
Is this the "correct" way to do it? I don't know. But I know it works and
that it allows me to do what I need to do programmatically. So if you're
stuck in the same kind of situation I was, hopefully this will help you out
in much less time and with much less frustration than I invested.
Rich
"Rich Hutchins" wrote:
Quote:
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 database.
>
I have a dataset in which a parameterized query returns the correct result
set in the forms of a tableadapter and a bindingnavigator. In other words, I
can perform my query and see that the tableadapter and bindingnavigator
contain the row(s) of data I expect.
>
What I want to do is make a decision in my program based on the value in one
of the columns in the tableadapter or bindingnavigator. Here's a short
example:
>
In my tableadapter and bindingnavigator, I can see the following columns and
values after running my query:
id = 2
partnumber = 12345
itemtype = OPT
>
Before I display a certain form, I want to know what the value of the
"itemtype" column is so I can customize the information on the form. So, in
pseudocode, I want to do:
>
If itemtype = 'OPT' Then
aControl.Enabled = TRUE
Else
aControl.Enabled = FALSE
End If
>
Where I'm stuck is the If itemtype = 'OPT'. How in the world do I find out
what the value is in that column in my tableadapter or bindingnavigator or am
I barking up the entirely wrong tree here?
>
Thanks in advance for any assistance.
>
Rich
>