2012年计算机二级ACCESS的参数化查询(4)
public accselect(string strsql, int total) {sql = strsql;
t = total;
}
///
/// 构造函数
///
/// 参数查询语句
/// 字节数
/// OBJECT值
public accselect(string strsql, int total, object value)
{
sql = strsql;
t = total;
v = value;
}
///
/// getOdd方法返回OleDbDataReader
///
/// 定义OleDbType类型
///
public OleDbDataReader getOdd(OleDbType odt)
{
OleDbConnection conns = new OleDbConnection(this.conn);
OleDbCommand cmd = new OleDbCommand(this.sql, conns);
OleDbParameter parm = new OleDbParameter("temp", odt, this.t);
parm.Direction = ParameterDirection.Input;
cmd.Parameters.Add(parm);
cmd.Parameters.Value = this.v;
conns.Open();
OleDbDataReader oda = cmd.ExecuteReader();
cmd.Dispose();
return oda;
}
页:
[1]