2014-03-12 72 views
-1

我有一个web服务从数据库获取byte []的列表。我希望能够返回所有的值。如何返回一个字节[]。Webservice返回字节数组

[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

什么是你的字节数组SQL Server中的数据类型? –

+0

模板的数据类型是图像 – user3284789

+0

你不认为'sr.getBytes()'? – Wibble

回答

1

像这样:

Template = (byte[])sr[3]; 

OR

Template = (byte[])sr["Template"]; 
+0

感谢此工作,但当我试图运行我的应用程序m_storedtemplate返回空值。 fgrTemplate [] m_StoredTemplate = verify.StudentVerifications(); – user3284789

相关问题