Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI friends,

I'm new to ASP.NET...

In my office I dont have permission to access SQL, & I want to perform some database related task like binding data to control or gridviewo updating data for my practise...

As I dont have access to SQL I'm thinking of using XML file as my DATABASE.......

so can u please tell me how to extract data from XML File and Binding it to GridView Control.....?
Posted

1 solution

An XML file cannot be a database in principle. But it can be used as a storage layer for some data model which is fully stored in memory during the lifetime of the application. In this case, the data layer along with the storage layer can really be used as a kind of a database.

It is really important to separate the data layer from the storage layer. For example, you need to perform the search in memory, not in XML, update memory, do transaction. XML should be only used when you really need to store the data on disk.

The best approach would be using Data Contract: http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

If you do it, you can forget XML: everything is already done for you. The serializer simply store any object graph to memory and restore it in exact same way in memory from a file or a stream. I mean it: an object graph of arbitrary topology, not just a tree (it means, the graph is allowed to have circular references, which is critically important for relational model). This approach is the most robust and at the same time is the easiest to use. It is non-intrusive: you only define your data classes, the serialization is defined by the contract and is already done. Basically all you do is adding some attributes to data types and members, which does not limit or modify behavior of your types.

Please see my past answers where I advocate this approach:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

—SA
 
Share this answer
 
Comments
prashantttt 18-Sep-13 0:34am    
So...
If I'm using Excel File as a database will it be goood...??
Sergey Alexandrovich Kryukov 18-Sep-13 1:31am    
I'm not sure... Why not XML? There are different approaches but using a spreadsheet and pretending it's the database... Probably, this is the worst variant... Why not Access then?.. Anyway, I think using proprietary stuff is always bad.

Anyway, your question was about XML, I answered in detail. Will you accept it formally (green button)?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900