-
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
-
Re: Datatable
How do you intend to decide which row is being shown?
-
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
-
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?
-
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.
-
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