Exemplo n.º 1
0
        public static bool OpenSql(DataTable table, String sql, String paramvalue, String pageinfo, String dsname)
        {
            try
            {
                InParams  inparams  = SDPClient.NewInParams();
                OutParams outparams = SDPClient.NewOutParams();

                inparams.SetRequestBody("ServiceName", "DataServices");
                inparams.SetRequestBody("ServiceItem", "OpenSql");
                inparams.SetRequestBody("SQL", sql);
                inparams.SetRequestBody("PageInfo", pageinfo);
                inparams.SetRequestBody("DataSource", dsname);

                if (TableUtil.IsAutoMetaData(table))
                {
                    inparams.SetRequestBody("AutoMetaData", "1");
                }
                else
                {
                    inparams.SetRequestBody("TableName", table.TableName);
                }

                inparams.SetRequestParams(paramvalue);

                SDPClient.CallService(inparams, outparams);

                DataTable resulttable = outparams.GetTableParam(0).GetDataTableValue();
                DataUtil.CopyTable(resulttable, table);

                TableUtil.SetProperty(table, "DataSource", outparams.GetStrParamValue("DataSource"));
                TableUtil.SetProperty(table, "Command", outparams.GetStrParamValue("Command"));

                return(true);
            }
            catch (Exception e)
            {
                System.Console.Out.WriteLine("DataServices.OpenSql Exception: {0}", e);
                throw e;
            }
        }