English 中文(简体)
About Sybase image
原标题:

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

问题回答

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.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签