How check datacolumn value

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

Guest

I have add a new Datacolum to DataTable like this

myDataCol.Expression = "(A * 100)/ B";

The problem is that B sometimes is 0 so I get the divided by zero error.

I would like something like if B <> 0 then....

Any Idea?
 
But... Why I get an error with tese sentences...

myDataSet.Tables["mitabla"].Columns["amtb"].DataType = typeof(Decimal);
myColumn = new DataColumn("COB", typeof(Decimal));
myColumn.Expression = "iif( amtb=0,0,100)"; <<<<< Error here
myDataSet.Tables["mitabla"].Columns.Add(myColumn);
 
What error?

Bahamas said:
But... Why I get an error with tese sentences...

myDataSet.Tables["mitabla"].Columns["amtb"].DataType = typeof(Decimal);
myColumn = new DataColumn("COB", typeof(Decimal));
myColumn.Expression = "iif( amtb=0,0,100)"; <<<<< Error here
myDataSet.Tables["mitabla"].Columns.Add(myColumn);



Alex Feinman said:
"iif( B = 0, 0, a * 100 / B )"
 
Really, I can't see the error message because the message is something like (
I translate roughly from Spanish message)

"The error message can't be showed because an additional resource is not
available"

How can I add this resources to see the message text?

I'm using VS2005 B2 and SQL CE 2005

The complete code with the error is:

myConn = new SqlCeConnection(myConnTxt);
myConn.Open();
//----------------
// Retry Data
//----------------
SqlCeCommand cmd = new SqlCeCommand(
"Select MYKEY"
+ ",sum(amt) amt,sum(amtpen) amtpen,sum(amt + amtpen) total,sum(amtpry)
amtpry"
+ ",sum(amtb) amtb,sum(amtyb) amtyb";
+ " From POCKET"
+ " where hp_year=" + combo_Year.Text + "and hp_mes=" + mes.ToString()
+ " group by MYKEY"
, myConn);
myDataSet = new DataSet("myDataset");
SqlCeDataAdapter myAdapter = new SqlCeDataAdapter(cmd);
myAdapter.Fill(myDataSet, "mitabla");
// Add a new calculated column
myDataSet.Tables["mitabla"].Columns["amtb"].DataType = typeof(Decimal); //
I think this line is not needed
myColumn = new DataColumn("COB", typeof(Decimal));
myColumn.Expression = "iif( amtb=0,0,100)"; // Error here <<<<<<
myDataSet.Tables["mitabla"].Columns.Add(myColumn);

If I remove the line with the Expression the program works.



Alex Feinman said:
What error?

Bahamas said:
But... Why I get an error with tese sentences...

myDataSet.Tables["mitabla"].Columns["amtb"].DataType = typeof(Decimal);
myColumn = new DataColumn("COB", typeof(Decimal));
myColumn.Expression = "iif( amtb=0,0,100)"; <<<<< Error here
myDataSet.Tables["mitabla"].Columns.Add(myColumn);



Alex Feinman said:
"iif( B = 0, 0, a * 100 / B )"

I have add a new Datacolum to DataTable like this

myDataCol.Expression = "(A * 100)/ B";

The problem is that B sometimes is 0 so I get the divided by zero
error.

I would like something like if B <> 0 then....

Any Idea?
 
The error messages a part of System.SR.cab - install it

Bahamas said:
Really, I can't see the error message because the message is something
like (
I translate roughly from Spanish message)

"The error message can't be showed because an additional resource is not
available"

How can I add this resources to see the message text?

I'm using VS2005 B2 and SQL CE 2005

The complete code with the error is:

myConn = new SqlCeConnection(myConnTxt);
myConn.Open();
//----------------
// Retry Data
//----------------
SqlCeCommand cmd = new SqlCeCommand(
"Select MYKEY"
+ ",sum(amt) amt,sum(amtpen) amtpen,sum(amt + amtpen) total,sum(amtpry)
amtpry"
+ ",sum(amtb) amtb,sum(amtyb) amtyb";
+ " From POCKET"
+ " where hp_year=" + combo_Year.Text + "and hp_mes=" + mes.ToString()
+ " group by MYKEY"
, myConn);
myDataSet = new DataSet("myDataset");
SqlCeDataAdapter myAdapter = new SqlCeDataAdapter(cmd);
myAdapter.Fill(myDataSet, "mitabla");
// Add a new calculated column
myDataSet.Tables["mitabla"].Columns["amtb"].DataType = typeof(Decimal);
//
I think this line is not needed
myColumn = new DataColumn("COB", typeof(Decimal));
myColumn.Expression = "iif( amtb=0,0,100)"; // Error here <<<<<<
myDataSet.Tables["mitabla"].Columns.Add(myColumn);

If I remove the line with the Expression the program works.



Alex Feinman said:
What error?

Bahamas said:
But... Why I get an error with tese sentences...

myDataSet.Tables["mitabla"].Columns["amtb"].DataType = typeof(Decimal);
myColumn = new DataColumn("COB", typeof(Decimal));
myColumn.Expression = "iif( amtb=0,0,100)"; <<<<< Error here
myDataSet.Tables["mitabla"].Columns.Add(myColumn);



:

"iif( B = 0, 0, a * 100 / B )"

I have add a new Datacolum to DataTable like this

myDataCol.Expression = "(A * 100)/ B";

The problem is that B sometimes is 0 so I get the divided by zero
error.

I would like something like if B <> 0 then....

Any Idea?
 
Back
Top