当前位置: 代码迷 >> Web Service >> wince开发,没法从传输连接中读取数据
  详细解决方案

wince开发,没法从传输连接中读取数据

热度:365   发布时间:2012-09-15 19:09:29.0
wince开发,无法从传输连接中读取数据。
开发摩托罗拉MC3190移动终端扫描设备,把设备连到电脑上调试,一切正常,把设备拔下来用无线,就提示无法从传输连接中读取数据。
具体是要把传过来的DataSet放到窗体上的DataGrid里。

补充:我又试了一下,如果传的DataSet是一行,就没有问题。两行,也没问题。行多了,就又问题了,该怎么设置呢?


WebService端是这样的
C# code
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Data.OracleClient;
using PobaService.ServiceReference1;

namespace PobaService
{
    /// <summary>
    /// Service1 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {
        static string connStr = "Data Source=192.168.100.1/orcl10G;user=mis;password=mis";
        OracleConnection oc = new OracleConnection(connStr);

        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public DataSet QuerySql(String sqlStr)
        {
            try
            {
                DataSet ds = new DataSet();
                OracleDataAdapter oda = new OracleDataAdapter(sqlStr, oc);
                oda.Fill(ds);
                return ds;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return null;
            }
        }
    }
}


窗体是这样的
C# code
using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using WZCS.WebReference;

namespace WZCS
{
    public partial class MatInvForm : Form
    {
        Service1 dbsvs new Service1();
        Form thatform;
        DataSet ds;
        public MatInvForm(Form thatform)
        {
            this.thatform = thatform;
            InitializeComponent(); 
        }

        private void MatInv_Load(object sender, EventArgs e)
        {
            ds = dbsvs.QuerySql("select t.cknum, t.ckname, t.matid, t.matcode, t.matname, t.specname, t.stuffname, t.countunit, t.invqty from (select t.cknum, t.ckname, t.matid, t.matcode, t.matname, t.specname, t.stuffname, t.countunit, t.invqty, rownum rn from VW_WZCS_MATINV t where rownum >= 1) t where rn <= 5");
            dgMatInv.DataSource = ds.Tables[0];
        }
    }
}


环境是IIS 7.5 在本机上 谢谢

------解决方案--------------------
无法从传输连接中读取数据。

是相关连接的问题,跟读取到数据之后异常是两回事。
换成无线后,无线连接是否能正常连到数据库。
  相关解决方案