Controls and Database Data

  • Thread starter Thread starter Adam Clark
  • Start date Start date
A

Adam Clark

I am wanting to get data into a common text box control without doing any
sort of "official" binding.

Here is what I have:

TextBox1.Text =
recordprocessor.nulltoalias(dsAssets.Tables("tblAssets").Rows(rCount).Item("
SerialNo"))

------------------------------------------------------



This works pretty good, however, is there an easier way to do this?
(recordprocessor is a class I wrote that takes any value and checks for null
values).

Seems like this is a lot of trouble.



Thanks



Adam
 
Adam Clark said:
I am wanting to get data into a common text box control without doing any
sort of "official" binding.

Here is what I have:

TextBox1.Text =
recordprocessor.nulltoalias(dsAssets.Tables("tblAssets").Rows(rCount).Item("
SerialNo"))

------------------------------------------------------



This works pretty good, however, is there an easier way to do this?
(recordprocessor is a class I wrote that takes any value and checks for null
values).

Seems like this is a lot of trouble.

Try using a strongly typed dataset.

So, the same thing that I use to do similar massaging is:

txtLastName.Text = Common.NullToNothing(dsAssets.tblAssets(rCount)("SerialNo"))

Which can be shortened if, instead of using dsAssets, use a reference to the
table directly:

Dim tbl As MyTypedDataTable = dsAssets.tblAssets

txtLastName.Text = Common.NullToNothing(tbl(rCount)("SerialNo"))


Anywho, not "TOO" much shorter, but it works :)

Mythran
 
Adam,
TextBox1.Text =
recordprocessor.nulltoalias(dsAssets.Tables("tblAssets").Rows(rCount).Item("
SerialNo"))

depends if you are filling more textboxes when that is true than you can do
dim dt as datatable = ds(dsAssets.Tables("tblAssets"))
TextBox1.Text = recordprocessor.nulltoalias(dt.Rows(rCount)("SerialNo"))

(It is not really a recordprocessor by the way it is an ItemProcessor, using
such a name would make in my opinion it more clear)

I hope this helps?

Cor
 
Back
Top