自定义DataSet
自定义DataSet,想用属性访问的方法访问内部表内指定行列的值。如下写法编译时没问题,但运行时报错,请高手指点。感谢
public class UserDataSet : DataSet
{
private DataTable tbError;
public UserDataSet()
{
tbError = new DataTable( "Error ");
DataColumn colFlg = new DataColumn( "ErrorFlg ", Type.GetType( "System.Int32 "));
tbError.Columns.Add(colFlg);
DataColumn colID = new DataColumn( "ErrorID ", Type.GetType( "System.String "));
tbError.Columns.Add(colID);
tbError.Rows[0][ "ErrorFlg "] = -1;
tbError.Rows[0][ "ErrorID "] = " ";
}
public int ErrorFLG
{
set
{
tbError.Rows[0][ "ErrorFlg "] = value;
}
get
{
return Convert.ToInt32(tbError.Rows[0][ "ErrorFlg "]);
}
}
public string ErrorID
{
set
{
tbError.Rows[0][ "ErrorID "] = value;
}
get
{
return tbError.Rows[0][ "ErrorID "].ToString();