请告诉我读者变量的数据类型应该是什么?
public Patient GetPatientInfo(string ID)
{
const string sql_get_patient_info = "Select * from dbo.Tb_Patient WHERE id=@ID";
Patient _p = new Patient();
DbCommand readCommand = _db.GetSqlStringCommand(sql_get_patient_info);
SqlDataReader reader = readCommand.ExecuteReader();
while (reader.Read())
{
_p.PatientName = reader["Name"].ToString();
_p.PatientDate = reader["Date"];
_p.PatientGender = reader["Gender"].ToString();
_p.PatientAge = reader["Age"].ToString();
_p.PatientContact = reader["Contact"].ToString();
_p.PatientOccupation = reader["Occupation"].ToString();
}
return _p;
}
答案 0 :(得分:0)
因为您正在使用DbCommand类,所以请调用
DbDataReader reader = readCommand.ExecuteDbDataReader();