最後,我找到了anwser。 這個問題的原因是在Sybase中訪問圖像大小的限制。當圖像大小高於37k字節時,輸出仍爲37K。因此,我在這一步錯過了一些字節。解決方案是您需要設置參數來檢索所有數據。 的部分代碼顯示如下:
[WebMethod]
public byte[] Image(string c, string r)
{
//check input ..
ConnectionDatabase connbaseloc = new ConnectionDatabase();
AseConnection conn1 = null;
AseCommand cmd1 = null;
string sqlstr1 = "";
AseDataReader reader = null;
byte[] Imagebytes = null;
try
{
using (conn1 = connbaseloc.Odbcconn_xxx())
{
string setTextCmd = " SET TEXTSIZE 130000"; //set parameter
cmd1 = new AseCommand(setTextCmd, conn1);
cmd1.ExecuteNonQuery();
sqlstr1 = "select ....";
cmd1 = new AseCommand(sqlstr1, conn1);
cmd1.CommandText = sqlstr1;
reader = cmd1.ExecuteReader();
while (reader.Read())
{
Imagebytes = (byte[])reader["Image"];
}
}
}
catch (Exception e)
{
//do something
}
finally
{
if (conn1 != null) conn1.Close();
}
return Imagebytes;
}
參數值取決於圖像的最大尺寸。