Expression Field not working in code.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table with a simple expression column. I'm multiplying quantity *
AveLaborRate to come up with total_labor. When I do the 'preview data' it
works fine, but when I run my program, all I get is the default 0. All of the
other fields have the same data as the preview.

What could be causing the total_labor field not to calculate?

Is there a way to view all of the contents in a table while I'm in debug
mode? FoxPro has the 'Browse' command. Is there anything similar in C#?

I'm using VS2005 C# and SQL 2005.
 
What datatypes are you using ?
Can you share the schema of your dataset ?
(do for example yourDsVariable.WriteXmlSchema( Console.Out ) )

To see the data inside the dataset, you can use the debugger visualizer that
appears if you hover with your mouse on the dataset variable (a magnifier
icon appears, and if you press it a viewer similar to the one you see when
you preview data will appear). The same magnifier appears if you add a watch
for the dataset.

Yet another way is using the Immediate Window (usually Ctrl+Alt_I) and then
execute
? yourDsVariable.GetXml()

--VV [MS]
(e-mail address removed)
 
What datatypes are you using ? double

Can you share the schema of your dataset ?
(do for example yourDsVariable.WriteXmlSchema( Console.Out ) )
I can't find the WriteXmlSchema method. My DS is gDataSet, but when I do a
'gDataSet.' the WriteXmlSchema is not listed. There is a GetDataSetSchema,
but I can't get it to work either. Sorry if this is simple stuff, but I'm
just learning OOP & C#.

In debug, I did look in the watch window, and the variable
'gtEstCrewLabor.TotalLabHourlyRateColumn.Expression' is empty. When I
manually add the expression in the watch window it works.

I checked the gDataSet.Designer.cs file, and the expression is in there.
It's the middle one below:

private void InitExpressions() {
this.EstCrewEqp.TotalRepHourlyRateColumn.Expression = "quantity
* AveRepHourlyRate";
this.EstCrewLabor.TotalLabHourlyRateColumn.Expression =
"quantity * AveLabHourlyRate";
this.usp_OpnCrewDetails.tot_lab_hrly_rateColumn.Expression =
"labquantity * labave_lab_base_rate";
}

I deleted the expression and re-entered it, but that didn't help. I did
notice that it was automatically removed and re-entered in the
gDataSet.Designer.cs file.

Any suggestions?

Thanks!


Vasco Veiga said:
What datatypes are you using ?
Can you share the schema of your dataset ?
(do for example yourDsVariable.WriteXmlSchema( Console.Out ) )

To see the data inside the dataset, you can use the debugger visualizer that
appears if you hover with your mouse on the dataset variable (a magnifier
icon appears, and if you press it a viewer similar to the one you see when
you preview data will appear). The same magnifier appears if you add a watch
for the dataset.

Yet another way is using the Immediate Window (usually Ctrl+Alt_I) and then
execute
? yourDsVariable.GetXml()

--VV [MS]
(e-mail address removed)

Irvin McCoy said:
I have a table with a simple expression column. I'm multiplying quantity *
AveLaborRate to come up with total_labor. When I do the 'preview data' it
works fine, but when I run my program, all I get is the default 0. All of
the
other fields have the same data as the preview.

What could be causing the total_labor field not to calculate?

Is there a way to view all of the contents in a table while I'm in debug
mode? FoxPro has the 'Browse' command. Is there anything similar in C#?

I'm using VS2005 C# and SQL 2005.
 
Back
Top