欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

水晶易表调用C#的WebService,返回数据集合的应用分析

程序员文章站 2024-03-01 17:53:28
1. 水晶易表不能识别ws接口返回的datatable或dataset数据类型,会提示“无法加载url” 3. c#调用oracle的package,并返回数据列表 2...

1. 水晶易表不能识别ws接口返回的datatable或dataset数据类型,会提示“无法加载url”

3. c#调用oracle的package,并返回数据列表

2. 经查证,可以接受string类型的,如果需要返回数据列表,那么需要借助数组来返回,代码实现如下:

复制代码 代码如下:

public weeksale_table getdata(string skc1, string skc2, string week1, string week2, string week3, string week4)
        {
            try
            {
         //c#调用oracle的包,返回数据列表
                oracleconnection orcn = new oracleconnection(configurationmanager.appsettings["sapbi"].tostring());
                oraclecommand cmd = new oraclecommand("pkg_cx_productlifecycle.skcweeksale", orcn);
                cmd.commandtype = commandtype.storedprocedure;
                oracleparameter ip0 = new oracleparameter("skc1", oracletype.varchar);
                oracleparameter ip1 = new oracleparameter("skc2", oracletype.varchar);
                oracleparameter ip2 = new oracleparameter("week1", oracletype.varchar);
                oracleparameter ip3 = new oracleparameter("week2", oracletype.varchar);
                oracleparameter ip4 = new oracleparameter("week3", oracletype.varchar);
                oracleparameter ip5 = new oracleparameter("week4", oracletype.varchar);

                ip0.value = skc1;
                ip1.value = skc2;
                ip2.value = week1;
                ip3.value = week2;
                ip4.value = week3;
                ip5.value = week4;

                cmd.parameters.add(ip0);
                cmd.parameters.add(ip1);
                cmd.parameters.add(ip2);
                cmd.parameters.add(ip3);
                cmd.parameters.add(ip4);
                cmd.parameters.add(ip5);

                oracleparameter p1 = new oracleparameter("p_rc", oracletype.cursor);
                p1.direction = system.data.parameterdirection.output;
                cmd.parameters.add(p1);

                oracledataadapter command = new oracledataadapter(cmd);
                dataset ds = new dataset();
                command.fill(ds, "table");
                datatable dt = ds.tables["table"];
                weeksale_table wt = new weeksale_table();
                wt.row = new weeksale_row[dt.rows.count];
                int rcount = dt.rows.count;
                for (int i = 0; i < rcount; i++)
                {
                    datarow dr = dt.rows[i];
                    weeksale_row row = new weeksale_row();
                    row.discount1 = dr["discount1"].tostring();
                    row.discount2 = dr["discount2"].tostring();
                    row.fcalcsums1 = dr["fcalcsums1"].tostring();
                    row.fcalcsums2 = dr["fcalcsums2"].tostring();
                    row.nums1 = dr["nums1"].tostring();
                    row.nums2 = dr["nums2"].tostring();
                    row.skc1 = dr["skc1"].tostring();
                    row.skc2 = dr["skc2"].tostring();
                    row.week = dr["week"].tostring();
                    row.weeks = dr["weeks"].tostring();
                    wt.row[i] = row;
                }
                return wt;
            }
            catch
            {
                return null;
            }
        }


复制代码 代码如下:

//定义row,一行
public class weeksale_row
    {
        public string weeks;
        public string skc1;
        public string skc2;
        public string fcalcsums1;
        public string fcalcsums2;
        public string nums1;
        public string nums2;
        public string discount1;
        public string discount2;
        public string week;
    }

//定义table
public class weeksale_table
    {
        public weeksale_row[] row;
    }