将表数据保存为 XML 文件
下面是我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你在寻找类似的东西吗?
are you looking for something like..
您可以使用 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.