views:

240

answers:

1

Hello everyone:

Does image data type be converted to byte array in sybase? I apply web service to get data set in sybase( image data type). I use byte[] to get returning of web service. Then i use the "response.binarywrite(byte[])" to show the image.(ASP.NET C#) But there' s a image distortion problem (When i zoon in the image, some points are missed). I don't know why Does anyone know the image data type in sybase could be transfered to byte array?

Original Image

Distortion Image

System:

1 Sybase

    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

+1  A: 

Hello! Finally, i find the anwser. The reason of this problem is the limitation of accessing size of image in Sybase. When the size of image is higher than 37k byte, the output is still 37K. Therefore, i miss some byte in this step. The solution is that you need to set the parameter to retrieve all data. The partial codes are showed as below:

    [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;
    }

The parameter value depends on your max size of images.

Fion