S
Siv
Hi,
This is driving me nuts, I have executed a SQL Stored Procedure that
populates a SQLDataReader (dr) and am reading in some fields that contain
numbers into a Struct that I have defined as follows:
=========================================
public struct KPIData
{
public byte Cond;
public Single Min;
public Single Max;
public Single Points;
public byte Band;
}
// I then instantiate an array called CSP with space for 11 items:
KPIData[] CSP;
CSP=new KPIData[10];
// Database stuff executes Stored Procedure and populates the DataReader
// Then eventually I do:
while (dr.Read())
{
CSP[n].Cond = (byte) dr["CondType"];
CSP[n].Min = (Single) dr["csMin"];
CSP[n].Max = (Single) dr["csMax"];
CSP[n].Points = (Single) dr["Points"];
CSP[n].Band = (byte) dr["Band"];
n += 1;
z= n % 10;
if (z== 0)
Array.Resize(ref CSP, CSP.Length + 10);
}
=========================================
The lines:
CSP[n].Min = (Single) dr["csMin"];
CSP[n].Max = (Single) dr["csMax"];
CSP[n].Points = (Single) dr["Points"];
All cause Explicit Type Conversion errors yet the byte ones work as I would
expect??
Can anyone explain to a Newbie why this is a problem, I have tried
substituting Float instead of Single and it still errors just the same???
This is driving me nuts, I have executed a SQL Stored Procedure that
populates a SQLDataReader (dr) and am reading in some fields that contain
numbers into a Struct that I have defined as follows:
=========================================
public struct KPIData
{
public byte Cond;
public Single Min;
public Single Max;
public Single Points;
public byte Band;
}
// I then instantiate an array called CSP with space for 11 items:
KPIData[] CSP;
CSP=new KPIData[10];
// Database stuff executes Stored Procedure and populates the DataReader
// Then eventually I do:
while (dr.Read())
{
CSP[n].Cond = (byte) dr["CondType"];
CSP[n].Min = (Single) dr["csMin"];
CSP[n].Max = (Single) dr["csMax"];
CSP[n].Points = (Single) dr["Points"];
CSP[n].Band = (byte) dr["Band"];
n += 1;
z= n % 10;
if (z== 0)
Array.Resize(ref CSP, CSP.Length + 10);
}
=========================================
The lines:
CSP[n].Min = (Single) dr["csMin"];
CSP[n].Max = (Single) dr["csMax"];
CSP[n].Points = (Single) dr["Points"];
All cause Explicit Type Conversion errors yet the byte ones work as I would
expect??
Can anyone explain to a Newbie why this is a problem, I have tried
substituting Float instead of Single and it still errors just the same???