当前位置: 首页>>代码示例>>C#>>正文


C# DataSet.WriteXmlSchema方法代码示例

本文整理汇总了C#中System.Data.DataSet.WriteXmlSchema方法的典型用法代码示例。如果您正苦于以下问题:C# DataSet.WriteXmlSchema方法的具体用法?C# DataSet.WriteXmlSchema怎么用?C# DataSet.WriteXmlSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Data.DataSet的用法示例。


在下文中一共展示了DataSet.WriteXmlSchema方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildRDLCStream

        public static Stream BuildRDLCStream(
            DataSet data, string name, string reportResource)
        {
            using (MemoryStream schemaStream = new MemoryStream())
            {
                // save the schema to a stream
                data.WriteXmlSchema(schemaStream);
                schemaStream.Seek(0, SeekOrigin.Begin);

                // load it into a Document and set the Name variable
                XmlDocument xmlDomSchema = new XmlDocument();
                xmlDomSchema.Load(schemaStream);
                xmlDomSchema.DocumentElement.SetAttribute("Name", data.DataSetName);

                // Prepare XSL transformation
                using (var sr = new StringReader(reportResource))
                using (var xr = XmlReader.Create(sr))
                {
                    // load the report's XSL file (that's the magic)
                    XslCompiledTransform xform = new XslCompiledTransform();
                    xform.Load(xr);

                    // do the transform
                    MemoryStream rdlcStream = new MemoryStream();
                    XmlWriter writer = XmlWriter.Create(rdlcStream);
                    xform.Transform(xmlDomSchema, writer);
                    writer.Close();
                    rdlcStream.Seek(0, SeekOrigin.Begin);

                    // send back the RDLC
                    return rdlcStream;
                }
            }
        }
开发者ID:inickvel,项目名称:SqlCeToolbox,代码行数:34,代码来源:RdlcHelper.cs

示例2: challanout

        public void challanout()
        {
            DataTable dt = new DataTable("challandt");
            dt = (DataTable)Session["challanout_dt"];

            DataSet ds = new DataSet();
            Viewer.Report.ChallanOutrpt crystalReport = new Report.ChallanOutrpt();
            string st = HttpContext.Current.Server.MapPath("~/ChallanOutCrpt1.rpt");

            //  Label1.Text = st;
            //   Response.Write(string.Format("<script language='javascript' type='text/javascript'>alert( "+st+") </script>"));

            crystalReport.Load(st);
            if (ds.Tables.Contains("challandt") == true)
            {
                ds.Tables.Remove("challandt");
            }
            ds.Tables.Add(dt);

            ds.WriteXmlSchema(HttpContext.Current.Server.MapPath("~/App_Data/Challanout.xml"));

            crystalReport.SetDataSource(dt);
            CrystalReportViewer1.ReportSource = crystalReport;

            crystalReport.ExportToHttpResponse
               (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "CHALLANOUTSHEET");
        }
开发者ID:spsinghdocument,项目名称:MVC3SG,代码行数:27,代码来源:ChallanoutViewer.aspx.cs

示例3: button1_Click

    private void button1_Click(object sender, EventArgs e)
    {
        string connectString = "Server=.\\SQLExpress;Database=adventureworkslt;Trusted_Connection=Yes";
      //create a dataset
			DataSet ds = new DataSet("XMLProducts");
			//connect to the pubs database and 
			//select all of the rows from products table

			SqlConnection conn = new SqlConnection(connectString);
            SqlDataAdapter da = new SqlDataAdapter("SELECT Name, StandardCost FROM SalesLT.Product", conn);
			da.Fill(ds, "Products");

      ds.Tables[0].Rows[0]["Name"] = "NewName";
      DataRow dr = ds.Tables[0].NewRow();
      dr["Name"] = "Unicycle";
      dr["StandardCost"] = "45.00";
      
      ds.Tables[0].Rows.Add(dr);
      ds.WriteXmlSchema("products.xdr");
      ds.WriteXml("proddiff.xml", XmlWriteMode.DiffGram);

      webBrowser1.Navigate(AppDomain.CurrentDomain.BaseDirectory + "/proddiff.xml");
      
      
      //load data into grid
			dataGridView1.DataSource = ds.Tables[0];
      
    }
开发者ID:ChegnduJackli,项目名称:Projects,代码行数:28,代码来源:frmDiffgram.cs

示例4: CreateSchema

        private void CreateSchema()
        {
            _ds = new DataSet("VehiclesRepairs");

            var vehicles = _ds.Tables.Add("Vehicles");
            vehicles.Columns.Add("VIN", typeof(string));
            vehicles.Columns.Add("Make", typeof(string));
            vehicles.Columns.Add("Model", typeof(string));
            vehicles.Columns.Add("Year", typeof(int));
            vehicles.PrimaryKey = new DataColumn[] { vehicles.Columns["VIN"] };

            var repairs = _ds.Tables.Add("Repairs");
            var pk = repairs.Columns.Add("ID", typeof(int));
            pk.AutoIncrement = true;
            pk.AutoIncrementSeed = -1;
            pk.AutoIncrementStep = -1;
            repairs.Columns.Add("VIN", typeof(string));
            repairs.Columns.Add("Description", typeof(string));
            repairs.Columns.Add("Cost", typeof(decimal));
            repairs.PrimaryKey = new DataColumn[] { repairs.Columns["ID"] };

            _ds.Relations.Add(
                "vehicles_repairs",
                vehicles.Columns["VIN"],
                repairs.Columns["VIN"]);

            _ds.WriteXmlSchema(_xsdFile);
        }
开发者ID:bazile,项目名称:Training,代码行数:28,代码来源:MainForm.cs

示例5: Main

        static void Main()
        {
            DataSet paymentRecord = new DataSet("PaymentSet");

            DataTable customers = paymentRecord.Tables.Add ( "Customers" );
            DataColumn customersId = customers.Columns.Add ( "Id", typeof (Guid) );
            customers.Columns.Add ( "FirstName", typeof (String) );
            customers.Columns.Add("LastName", typeof(String));
            customers.Columns.Add("MiddleName", typeof(String));
            customers.Columns.Add("Number", typeof(String));
            customers.PrimaryKey = new []{customersId};

            DataTable payments = paymentRecord.Tables.Add ( "Payments" );
            DataColumn paymentsId = payments.Columns.Add ( "Id", typeof (Guid) );
            payments.Columns.Add ( "PaymentDate", typeof (DateTime) );
            payments.Columns.Add ( "MonthPaid", typeof (DateTime) );
            payments.Columns.Add ( "Amount", typeof (decimal) );
            payments.Columns.Add ( "Rate", typeof (decimal) );
            DataColumn custIdForeign = payments.Columns.Add ( "CustomerId", typeof (Guid) );
            payments.PrimaryKey = new [] { paymentsId };

            paymentRecord.Relations.Add ( "CustomerIdForeignKey", customersId, custIdForeign );

            StreamWriter writer = new StreamWriter ( "PaymentSet.xsd" );
            paymentRecord.WriteXmlSchema ( writer );
            writer.Close();
        }
开发者ID:altmer,项目名称:study-projects,代码行数:27,代码来源:Program.cs

示例6: SaveDataSetAsXml

        public static void SaveDataSetAsXml(DataSet set, string fileName)
        {
            string file = Regex.Replace( fileName, extPattern, fileName );
             fileName = VerifyFileExt( fileName, ".xml" );

             set.WriteXml( fileName );
             set.WriteXmlSchema( file + ".xsd" );
        }
开发者ID:ghostmonk,项目名称:CSharpTutorials,代码行数:8,代码来源:DbUtils.cs

示例7: Main

        static void Main(string[] args)
        {
     // Создание Таблицы DataTable с именем "Cars"
            DataTable tablCars = new DataTable("Cars");
            // Создание столбцов
            DataColumn carsId = new DataColumn("Id", typeof(int));
            DataColumn carsName = new DataColumn("Name", typeof(string));
            DataColumn carsCountry = new DataColumn("Country", typeof(string));
            DataColumn carsPrice = new DataColumn("Price", typeof(double));
            tablCars.Columns.AddRange(new DataColumn[] { carsId, carsName, carsCountry, carsPrice });
            // Создание строки с данными 
            DataRow newRow1 = tablCars.NewRow();
            newRow1["Name"] = "BMW"; newRow1["Country"] = "Germany";
            newRow1["Price"] = "50000";
            tablCars.Rows.Add(newRow1);

            DataRow newRow2 = tablCars.NewRow();
            newRow2["Name"] = "Audi"; newRow2["Country"] = "Germany";
            newRow2["Price"] = "37500";
            tablCars.Rows.Add(newRow2);

            // Сохранить ТАБЛИЦЫ  tablCars  в виде XML
            tablCars.WriteXml("Cars.xml");
            tablCars.WriteXmlSchema("CarsSchema.xsd");
         

      // Создание Таблицы DataTable с именем "Drivers"
            DataTable tablDrivers = new DataTable("Drivers");
            // Создание столбцов
            DataColumn drId = new DataColumn("Id", typeof(int));
            DataColumn drName = new DataColumn("Name", typeof(string));
            DataColumn drAge = new DataColumn("Age", typeof(string));
            tablDrivers.Columns.AddRange(new DataColumn[] { drId, drName, drAge });
            // Создание строки с данными 
            DataRow newRow3 = tablDrivers.NewRow();
            newRow3["Name"] = "Ivan"; newRow3["Age"] = "33";
            tablDrivers.Rows.Add(newRow3);

            DataSet dataSet = new DataSet("AutoPark");
            dataSet.Tables.AddRange(new DataTable[] { tablCars, tablDrivers});


            // Сохранить DATASET  в виде XML
            dataSet.WriteXmlSchema("AutoParkSchema.xsd");
            dataSet.WriteXml("AutoPark.xml");
            
            
            // Очистить DataSet.
            dataSet.Clear();

            Console.WriteLine("XML успешно сформированы!");

            Console.ReadKey();

        }
开发者ID:Saroko-dnd,项目名称:My_DZ,代码行数:55,代码来源:Program.cs

示例8: Main

        static void Main()
        {
            string strConn = "Data Source=localhost;Initial Catalog=booksourcedb;Integrated Security=True";
              string strSql = "SELECT * FROM book";
              SqlDataAdapter dataAdapter = new SqlDataAdapter(strSql, strConn);

              DataSet dataSet = new DataSet("booklist");
              dataAdapter.Fill(dataSet, "book");

              dataSet.WriteXml(@"C:\Temp\booklist.xml");
              dataSet.WriteXmlSchema(@"C:\Temp\booklist.xsd");
        }
开发者ID:Choyoungju,项目名称:XMLDTD,代码行数:12,代码来源:WriteXmlAndSchema.cs

示例9: WriteSchema

        private void WriteSchema()
        {
            DataSet ds = new DataSet();
              StringBuilder sb = new StringBuilder(1024);

              ds.ReadXml(AppConfig.GetEmployeesFile());

              ds.WriteXml(AppConfig.XmlFile);
              ds.WriteXmlSchema(AppConfig.XsdFile);

              txtResult.Text = File.ReadAllText(AppConfig.XsdFile);
        }
开发者ID:ah16269,项目名称:rest-web-api-wcf,代码行数:12,代码来源:03-WriteDataSet.xaml.cs

示例10: CreateMcfDataSet

 /// <summary>
 /// Creates XSD schema for Hydromet MCF
 /// Loads MCF csv files into strongly typed DataSet
 /// </summary>
 public static void CreateMcfDataSet(string path)
 {
     DataSet ds = new DataSet("McfDataSet");
     foreach (var item in tableNames)
     {
         string fn = Path.Combine(path, item + ".csv");
         var csv = new CsvFile(fn);
         csv.TableName = item+"mcf";
         ds.Tables.Add(csv);
     }
     ds.WriteXml(Path.Combine(path,"mcf.xml"));
     ds.WriteXmlSchema(Path.Combine(path, "mcf.xml"));
 }
开发者ID:usbr,项目名称:Pisces,代码行数:17,代码来源:McfUtility.cs

示例11: Generate

 public static string Generate(DataSet dataSet, CodeNamespace codeNamespace, CodeDomProvider codeProvider)
 {
     if (codeProvider == null)
     {
         throw new ArgumentNullException("codeProvider");
     }
     if (dataSet == null)
     {
         throw new ArgumentException(System.Design.SR.GetString("CG_DataSetGeneratorFail_DatasetNull"));
     }
     StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
     dataSet.WriteXmlSchema(writer);
     return Generate(writer.GetStringBuilder().ToString(), null, codeNamespace, codeProvider);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:14,代码来源:TypedDataSetGenerator.cs

示例12: hacer_report

        public void hacer_report(String idcomprobante)
        {
            ParameterDiscreteValue parametro=new ParameterDiscreteValue();
            ParameterFields paramlist = new ParameterFields();

            DataSet ds = new DataSet("comprobante");
            db.ejecutar("select envnumcomprobante,envfecha_registro,if(clitipo=0,(select concat(natnombres,' ',natapellidos) from ste_clinatural where idclinatural=idcliente),(select jurrazonsocial from ste_clijuridico where idste_clijuridico=idcliente)) as nomcliente, cliruc, envdestinatario, envrucdestinatario, envdireccion_destino,envdireccion_origen,'" + this.txtrucremitente.Text + "' as rucremitente, ste_envio.gremision from ste_envio inner join ste_cliente on ste_envio.envidcliente=ste_cliente.idcliente where idenvio=" + idcomprobante);
            ds.Tables.Add(db.gettabla());
            db.ejecutar("select * from ste_detalleenvio where denidenvio=" + idcomprobante);
            ds.Tables.Add(db.gettabla());
            db.ejecutar("select * from ste_camionero inner join ste_unidad on ste_unidad.uniidcamionero=ste_camionero.idcamionero where ste_unidad.idunidad=" + this.cbunidad.SelectedIndex);
            ds.Tables.Add(db.gettabla());
            ds.WriteXmlSchema("./comprobante.xml");
            CrystalDecisions.CrystalReports.Engine.ReportClass rpt;
            switch (cmbtipcomprobante.SelectedIndex)
            {
                case 0://boleta
                    rpt = new reportes.boletadeventa();
                    break;
                case 1://factura
                    rpt = new reportes.factura();
                    double subt=0;
                    foreach (DataRow r in ds.Tables[1].Rows) {
                        subt +=Double.Parse(r["dencantidad"].ToString()) * Double.Parse(r["denpreciounitario"].ToString());
                        //subt += ((Double)r["dencantidad"]) * ((Double)r["denpreciounitario"]);
                    }
                    parametro.Value = aletras(subt.ToString(),true);
                    paramlist.Add("enletras", ParameterValueKind.StringParameter, DiscreteOrRangeKind.DiscreteValue).CurrentValues.Add(parametro);
                    break;
                default://orden de despacho
                    rpt = new reportes.ordendedespacho();
                    break;
            }
            rpt.SetDataSource(ds);
            //FACTURA
            formularios.Imprimir frmr = new formularios.Imprimir(rpt);
            frmr.crystalReportViewer1.ParameterFieldInfo = paramlist;
            frmr.ShowDialog(this);
            //GUIA DE REMISION
            if (cmbtipcomprobante.SelectedIndex==1)
            {
                rpt = new reportes.guiaderemision();
                rpt.SetDataSource(ds);
                frmr = new formularios.Imprimir(rpt);
                //frmr.crystalReportViewer1.ParameterFieldInfo = paramlist;
                frmr.ShowDialog(this);
            }
        }
开发者ID:yodanielo,项目名称:grupo-selva-central,代码行数:48,代码来源:frmcomprobante.cs

示例13: CargarData

        private void CargarData()
        {
            DataTable project = new DataTable("Project");

            dataSet = new DataSet();
            dataSet.Tables.Add(project);

            project.Columns.Add("Id", typeof(int));
            project.Columns.Add("ParentId", typeof(int));
            project.Columns.Add("Name", typeof(string));

            project.Rows.Add(0, DBNull.Value, "Sellout");
            project.Rows.Add(1, 0, "Proceso de Importacion");
            project.Rows.Add(2, 1, "Importacion de Sellout");
            project.Rows.Add(3, 1, "Importacion de Clientes");

            project.Rows.Add(4, 0, "Proceso de Calculos");
            project.Rows.Add(5, 4, "Calculos de ABC");
            project.Rows.Add(6, 4, "Calculos de Oportunidades");
            project.Rows.Add(7, 4, "Calculos de KPIs");

            project.Rows.Add(8, 0, "Mantenimientos de Datos");
            project.Rows.Add(10, 8, "Clientes");
            project.Rows.Add(11, 8, "Agrupacion de Clientes");
            project.Rows.Add(12, 8, "Master de Productos KC");
            project.Rows.Add(13, 8, "Productos Equivalentes");
            project.Rows.Add(14, 8, "Agrupoacion de Productos");
            project.Rows.Add(15, 8, "Distribuidores");
            project.Rows.Add(16, 8, "KAMs");
            project.Rows.Add(17, 8, "Pais");
            project.Rows.Add(18, 8, "Segmentos");
            project.Rows.Add(19, 8, "Nuevos Segmentos");
            project.Rows.Add(20, 8, "Conglomerados");
            project.Rows.Add(21, 8, "Cuentas Globales");

            project.Rows.Add(22, DBNull.Value, "Sellin");

            project.Rows.Add(26, DBNull.Value, "MKTOOLS");

            dataSet.WriteXml(@"source.xml");
            dataSet.WriteXmlSchema(@"XMLSchema.xsd");
        }
开发者ID:npvb,项目名称:CRM-TOOLS---Project,代码行数:42,代码来源:Principal.cs

示例14: CreateXmlSchema

        /// <summary>
        /// Creates a schema file from an xmldocument file
        /// </summary>
        /// <param name="sXmlFilePath"></param>
        /// <returns></returns>
        public static string CreateXmlSchema(string sXmlFilePath)
        {
            string sXmlSchemaPath = FileUtilities.GetUniqueTempFileName();

            try
            {
                DataSet dsXmlDoc = new DataSet();
                dsXmlDoc.ReadXml(sXmlFilePath);
                dsXmlDoc.WriteXmlSchema(sXmlSchemaPath);

                dsXmlDoc.Clear();
                dsXmlDoc = null;
            }
            catch (Exception ex)
            {
                throw new Exception("CreateXmlSchema", ex);
            }

            return sXmlSchemaPath;
        }
开发者ID:chambleton,项目名称:datafile-to-xml-converter,代码行数:25,代码来源:XmlValidator.cs

示例15: BuildRDLC

        /// <summary>
        /// constructs a simple report RDLC file based on a DataSet
        /// </summary>
        /// <param name="data"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        public static string BuildRDLC(DataSet data, string name)
        {
            // establish some file names
            string virtualXslt = "xslt/rdlc.xsl";
            string virtualRdlc = "rdlc/" + name + ".rdlc";
            string virtualSchema = "rdlc/" + name + ".schema";

            // set the NAME on the DataSet
            // this may or may not be necessary, but the RDLC and DataSet
            // will both have the same name if this is done.
            data.DataSetName = name;

            // write the DataSet Schema to a file
            // we should be passing a DataSet with only one DataTable
            // the rdlc.xsl does not account for multiple DataTables
            string physicalSchema = HttpContext.Current.Server.MapPath(virtualSchema);
            data.WriteXmlSchema(physicalSchema);

            // load the DataSet schema in a DOM
            XmlDocument xmlDomSchema = new XmlDocument();
            xmlDomSchema.Load(physicalSchema);

            // append the NAME to the schema DOM
            // this is so we can pick it up in the rdlc.xsl
            // and use it
            xmlDomSchema.DocumentElement.SetAttribute("Name", name + "_Table");

            // transform the Schema Xml with rdlc.xsl
            string physicalXslt = HttpContext.Current.Server.MapPath(virtualXslt);
            string xml = HRWebsite.General.TransformXml(xmlDomSchema.OuterXml, physicalXslt);

            // save off the resultng RDLC file
            string physicalRdlc = HttpContext.Current.Server.MapPath(virtualRdlc);
            XmlDocument xmlDomRdlc = new XmlDocument();
            xmlDomRdlc.LoadXml(xml);
            xmlDomRdlc.Save(physicalRdlc);

            // return the virtual path of the RDLC file
            // this is needed by the asp:ReportViewer
            return virtualRdlc;
        }
开发者ID:luiseduardohdbackup,项目名称:dotnet-1,代码行数:47,代码来源:RDLCHelper.cs


注:本文中的System.Data.DataSet.WriteXmlSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。