views:

44

answers:

2

Bellow 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 dont 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 grateful.

+1  A: 

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");
Muhammad Akhtar
you just show the path .There's no syntax to store data from database as xml
shamim
NorthwindDataContext db = new NorthwindDataContext(); var r = from p in db.Categories select p;I can not write .r.WriteXml("String FileName Where you want to store");How to write it?
shamim
convert it into data table and data table have this method support
Muhammad Akhtar
A: 

Hey,

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.

Brian
Great thanks .Really it's easy in LINQ.Thanks again
shamim