1

sybase中图像数据类型是否转换为字节数组?我应用 Web 服务来获取 sybase 中的数据集(图像数据类型)。我使用 byte[] 来返回 Web 服务。然后我使用“response.binarywrite(byte[])”来显示图像。(ASP.NET C#)但是有一个图像失真问题(当我放大图像时,有些点被遗漏了)。我不知道为什么有人知道sybase中的图像数据类型可以传输到字节数组吗?

原始图像

失真图像

系统:

1 赛贝斯

    Sybase db: 11.9.2

    Adaptive server enterprise 12.5.1

    Sybase.Data.AseClient:1.0.152.0

2 ASP.NET C# (Visual Studio 2008)

3 IE6

4

1 回答 1

4

最后,我找到了答案。出现此问题的原因是 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;
    }

参数值取决于您的最大图像大小。

于 2009-12-15T08:50:51.150 回答