求助关于sqlreader取不了空值的问题
首先,我想在我的程序中通过sqlreader来读取数据库中的数据然后用sqlreader[i].getstring方法来填充我的新实例。具体代码如下:
public class ColumnInfo
{
private string _id;
private string _fid;
private int _sort;
private DateTime _time;
private int _childsum;
private string _name;
private string _desc;
private int _status;
public ColumnInfo()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public ColumnInfo(string id, string fid, int sort, DateTime time, int childsum, string name, string desc,
int status)
{
this._id = id;
this._fid = fid;
this._sort = sort;
this._time = time;
this._childsum = childsum;
this._name = name;
this._desc = desc;
this._status = status;
}...这是部分代码
这里另外一个类的部分代码:
SqlDataReader sdr = SQLHelper.ExecuteReader(SQLHelper.CONN_STRING, CommandType.Text, SQL_SELECT_COLUMN, SParms)
if (sdr.Read())
{
return new ColumnInfo(sdr.getGuid(0).toString(),sdr.getGuid(1).toString(),sdr.getInt32(2),sdr.getDateTime(3),sdr.getInt32(4), sdr.getString(5), sdr.getString(6),sdr.getint32(7));
}
就这样,但是数据库有些字段是NULL,这时运行就会抛出异常“
关于.net下服务安装_Asp.Net基础教程