I have read the threads on here about adding a calculated column to a dataset
to get the concatenation of first and last name fields into a single name
field and then binding the calculated field to the control on a form.
I am coming to VB.NET and ADO.NET and SQL Server from Visual Foxpro with its
embedded SQL. I'm used to being to combine fields on the fly inside my sql
statement.
Is it true that this can not be done using the above tools and in the above
scenario?
Must one always create caluclated fields by adding them to a dataset?
Please note.. I'm not arguing for or against VFP vs VB... I just want to
make sure I'm not missing an alternative that might exist that resembles the
VFP way.
Also.. while on the topic... I am having difficulty in getting the
calculated field's name to show up as a display member option for a combobox
control who's dropdown style is dropdown list.
I am using this code in the form's load event without error but without the
desired result:
Customers1.Clear()
Dim dc As DataColumn
dc = New DataColumn("Name")
dc.DataType = System.Type.GetType("System.String")
dc.Expression = "lname + ', ' + fname"
Customers1.Tables(0).Columns.Add(dc)
OleDbDataAdapter1.Fill(Customers1)
The code doesn't generate an error but the new datacolumn "Name" does not
show up in the display member field on the properties sheet for the control.
Before I tried using the calculated field, my code was this...
Customers1.Clear()
OleDbDataAdapter1.Fill(Customers1)
....and the display member showed the fields and I could bind them to the
control.
Please note I am able to see the calculated column when I preview the data
set.
Should my new code BE somewhere else rather than form load event?
If you have the time to comment, I'd appreciate it.