Reputation: 6778
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.
Upvotes: 0
Views: 1212
Reputation: 50728
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.
Upvotes: 0
Reputation: 52241
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");
Upvotes: 2