我有一个web服务,它从db获取byte []列表。我希望能够返回所有值。如何返回字节[]。
[WebMethod]
public List<fgrTemplate> StudentVerifications()
{
List<fgrTemplate> listOfFgrTemp = new List<fgrTemplate>();
cn.Open();
SqlCommand com = new SqlCommand("SELECT Template FROM tblFingerprint", cn);
SqlDataReader sr = com.ExecuteReader();
while (sr.Read())
{
fgrTemplate fingerprint = new fgrTemplate()
{
ID = sr.GetInt32(0),
StudentID = sr.GetInt32(1),
Description = sr.GetString(2)
Template = sr.GetByte??
};
listOfFgrTemp.Add(fingerprint);
}
cn.Close();
return listOfFgrTemp;
}
答案 0 :(得分:1)
像这样:
Template = (byte[])sr[3];
OR
Template = (byte[])sr["Template"];