Webservice之Dataset传输[客户端]

4 篇文章 0 订阅
3 篇文章 0 订阅
using System.IO;
using System.IO.Compression;
using System.Data;
using System.Data.SqlClient;
using System.Runtime.Serialization.Formatters.Binary;

//DataSet
        #region
private void BindDataSet(DataSet ds)
    {
        //this.GridView1.DataSource = null;
        //this.GridView1.DataSource = ds.Tables[0];
        //this.GridView1.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        localhost. Service1 ws = new localhost.Service1();
        DateTime dtBegin = DateTime .Now;
        DataSet ds = ws.GetDataSet();
        this.Label1.Text = string .Format("耗时 : {0}",DateTime.Now-dtBegin);
        BindDataSet(ds);
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        localhost. Service1 ws = new localhost.Service1();
        DateTime dtBegin = DateTime .Now;
        byte[] buffer = ws.GetDataSetBytes();
        BinaryFormatter ser = new BinaryFormatter();
        DataSet ds = ser.Deserialize(new MemoryStream(buffer)) as DataSet;
        this.Label2.Text = string .Format("耗时 : {0};   大小:{1}" , DateTime.Now - dtBegin,buffer.Length.ToString());
        BindDataSet(ds);
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        localhost. Service1 ws = new localhost.Service1();
        DateTime dtBegin = DateTime .Now;
        byte[] buffer = ws.GetDataSetSurrogateBytes();
        BinaryFormatter ser = new BinaryFormatter();
        dss. DataSetSurrogate dss = ser.Deserialize(new MemoryStream(buffer)) as dss.DataSetSurrogate;
        DataSet ds = dss.ConvertToDataSet();
        this.Label3.Text = string .Format("耗时 : {0};   大小:{1}" , DateTime.Now - dtBegin,buffer.Length.ToString());
        BindDataSet(ds);
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        localhost. Service1 ws = new localhost.Service1();
        DateTime dtBegin = DateTime .Now;
        byte[] zipBuffer = ws.GetDataSetSurrogateZipBytes();
        byte[] buffer = UnZipClass .Decompress(zipBuffer);
        BinaryFormatter ser = new BinaryFormatter();
        dss. DataSetSurrogate dss = ser.Deserialize(new MemoryStream(buffer)) as dss.DataSetSurrogate;
        DataSet ds = dss.ConvertToDataSet();
        this.Label4.Text = string .Format("耗时 : {0};   大小:{1}" , DateTime.Now - dtBegin,zipBuffer.Length.ToString());
        BindDataSet(ds);
    }
  #endregion

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值