将表数据保存为 XML 文件

发布于 2024-09-12 05:55:51 字数 1117 浏览 6 评论 0原文

下面是我的 SQL 语法:

CREATE TABLE [dbo].[Security_Module_Info](
    [Client_Company_ID] [smallint] NOT NULL,
    [Module_ID] [tinyint] NOT NULL,
    [Module_Name] [nvarchar](50) NULL,
    [Module_Description] [nvarchar](200) NULL,
    [Is_Active] [bit] NULL,
    [Active_Date] [smalldatetime] NULL,
    [Record_Status] [tinyNULL,
    [Maker_ID] [smallint] NULL,
    [Make_Date] [smalldatetime] NULL,
    [Checker_ID] [smallint] NULL,
    [Check_Date] [smalldatetime] NULL,
    [Authorizer_ID] [smallint] NULL,
    [Authorize_Date] [smalldatetime] NULL,
    [Record_Action_Type] [tinyint] NULL,
CONSTRAINT [PK_Security_Module_Info] PRIMARY KEY CLUSTERED 
(
    [Client_Company_ID] ASC,
    [Module_ID] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

我想在项目的 App_Data 文件夹中创建一个 XML 文件。此 XML 用作我的 AspxMenu 的源文件。我知道如何将 XML 数据绑定到 AspxMenu,但我不知道如何创建 XML 文件。我想将此表信息保存为 App_Data 文件夹中的 XML 文件。帮助我将表信息保存为 XML 文件。

欢迎任何建议、建议和回复。

Below is my SQL syntax:

CREATE TABLE [dbo].[Security_Module_Info](
    [Client_Company_ID] [smallint] NOT NULL,
    [Module_ID] [tinyint] NOT NULL,
    [Module_Name] [nvarchar](50) NULL,
    [Module_Description] [nvarchar](200) NULL,
    [Is_Active] [bit] NULL,
    [Active_Date] [smalldatetime] NULL,
    [Record_Status] [tinyNULL,
    [Maker_ID] [smallint] NULL,
    [Make_Date] [smalldatetime] NULL,
    [Checker_ID] [smallint] NULL,
    [Check_Date] [smalldatetime] NULL,
    [Authorizer_ID] [smallint] NULL,
    [Authorize_Date] [smalldatetime] NULL,
    [Record_Action_Type] [tinyint] NULL,
CONSTRAINT [PK_Security_Module_Info] PRIMARY KEY CLUSTERED 
(
    [Client_Company_ID] ASC,
    [Module_ID] ASC
) WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

I want to create a XML file on my project's App_Data folder. This XML use as the source file of my AspxMenu. I know how to bind XML data to AspxMenu but I don't know how to create XML file .I want to save this table information as a XML file on my App_Data folder. Help me to save table information as a XML file.

Any suggestion, advice and reply is welcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

诠释孤独 2024-09-19 05:55:51

你在寻找类似的东西吗?

System.Data.DataTable dtbl = new System.Data.DataTable();
//dtbl fill your datatable from DB here
dtbl.WriteXml("String FileName Where you want to store");

are you looking for something like..

System.Data.DataTable dtbl = new System.Data.DataTable();
//dtbl fill your datatable from DB here
dtbl.WriteXml("String FileName Where you want to store");
鹿童谣 2024-09-19 05:55:51

您可以使用 LINQ to XML (http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx )也作为复制数据的一种方法。您不必转换为数据表。 LINQ to XML 可以通过循环访问结果集并将对象的数据写入 XML 来完成。另外,您可以尝试 XML 序列化程序 (http:// /msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx)来转换对象,但如果该对象具有任何实体集关系,则可能会引发错误(XML 序列化可以我认为只序列化到这么多级别)。

HTH。

You could use LINQ to XML (http://www.hookedonlinq.com/LINQtoXML5MinuteOverview.ashx) as a means to copy the data over too. You don't have to convert to data table. LINQ to XML would be done by looping through your resultset and writing the object's data to the XML. Also, you could try an XML serializer (http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer.aspx) to convert the object, but if that object has any entity set relationships this may throw an error (XML Serialization can only serialize to so many levels I think).

HTH.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文