添加Web引用不是服务引用

Posted on 2014-01-07 23:00  哥德巴赫猜  阅读(278)  评论(0编辑  收藏  举报

目的:地址写在代码中,不是配置文件里。引用这个类库的时候不需要配置文件。

 public JianPinForm()
        {

            InitializeComponent();
            
            OracleHelpers.Url = WebServiceConfig.Wsc.webConfigStr;//初始化的时候重新指定了路径

            jianpinTable = GetTable();
            if (jianpinTable != null && jianpinTable.Rows.Count > 0)
            {
                this.dgvJP.DataSource = jianpinTable;
            }
        }

        //请不要调换这里的位置 就让他安静的呆着吧
        OracleHelperService.OracleHelper_zjyjy OracleHelpers = new OracleHelperService.OracleHelper_zjyjy();


        public DataTable GetTable()
        {
            DataTable contentDt = new DataTable("dt");
            //查询检品信息
            string strSql = "SELECT c_jianpinmc as \"检品名称\",c_jianpinbh as \"检品编号\",c_shoujianrq as \"收检日期\",c_baogaorq as \"报告日期\",c_pihao as \"批号\",c_guige as \"规格\",c_baozhuang as \"包装\",c_yangpinlb as \"类别\", " +
                            "c_jixing as \"剂型\",c_shengchangbcm as \"生产厂家\",c_gongyangdw as \"供样(报验)单位\",c_songyangdw as \"送样单位\",c_jianyanmd as \"检验目的\",c_jianyanxm as \"检验项目\",c_jianyanyj as \"检验标准\",c_zhujianks as \"主检科室\" " +
                            " from sample";

            contentDt = OracleHelpers.GetDataTableNoParam(strSql);

            return contentDt;
        }

-----WebServiceConfig文件

 public string webConfigStr = string.Empty;
        public WebServiceConfig()
        {
            //本地测试访问
            webConfigStr = "http://192.168.0.11/yjs_WebServiceOracleHelper/OracleHelper_zjyjy.asmx";//
            //服务器地址测试访问
            //   webConfigStr = "http://localhost:33046/OracleHelper.asmx";
        }

        static WebServiceConfig wsc;
        public static WebServiceConfig Wsc
        {
            get
            {
                if (wsc == null)
                {
                    wsc = new WebServiceConfig();
                }
                return WebServiceConfig.wsc;
            }
        }

Copyright © 2024 哥德巴赫猜
Powered by .NET 9.0 on Kubernetes