Webservice返回字节数组
本文关键字:数组 字节数 字节 返回 Webservice | 更新日期: 2023-09-27 17:49:40
我有一个web服务,从数据库中获取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;
}
像这样:
Template = (byte[])sr[3];
或
Template = (byte[])sr["Template"];