|
-
Apr 4th, 2011, 11:15 AM
#1
Thread Starter
Addicted Member
Datatable
i gurus
I have a select statement and it will go to a datatable object, I would like to do the following
textbox1.text=datatable(first field value)
textbox2.text=datatable(second field value)
textbox3.text=datatable(third field value)
please help and thanks a bunch
-
Apr 4th, 2011, 12:06 PM
#2
Re: Datatable
How do you intend to decide which row is being shown?
My usual boring signature: Nothing
 
-
Apr 4th, 2011, 02:02 PM
#3
Thread Starter
Addicted Member
Re: Datatable
shaggy
thanks for jumping in, the result from the select statement should only be one row of information, and is in here where I need the help.
Thanks again a bunch
-
Apr 4th, 2011, 02:07 PM
#4
Re: Datatable
If there will only be one row, then access the first row in the DataTable via the Rows property. Then access the fields of said row by either their column indexes or column names.
May I also suggest that you upgrade to at least VS2008?
-
Apr 4th, 2011, 02:17 PM
#5
Re: Datatable
What ForumAccount said is the way I would do it. I would also use the field names rather than the field ordinals, simply because the field names remain ok even if you change your SQL statement to include more fields, or include them in a different order.
It would look something like this:
TextBox1.Text = YourDatatable.Rows(<the row you want>).Items("<Your item name here>").ToString
That way, you could build this into a sub that took the row number as an argument, and you could use it to navigate through the rows, if that was of interest.
My usual boring signature: Nothing
 
-
Apr 4th, 2011, 03:13 PM
#6
Thread Starter
Addicted Member
Re: Datatable
thanks F/S
So in my case this will be
textbox1.text=datatable.rows(0).items("First").tostring
textbox2.text=datatable.rows(0).items("last").tostring
I am ok in my line
Thanks again
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|