473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

fill the xml by using datatable

Hello experts,I have one small doubt i am getting the values from database and filled the datatable.But i don't know how to convert this datatable data to xml.Actually this is my code

string query = "SELECT TOP 10 * FROM Details";
SqlConnection cn = new SqlConnection(connectionstring);
cn.Open();
SqlDataAdapter adpt = new SqlDataAdapter(new SqlCommand(query, cn));
System.Data.DataTable dt = new System.Data.DataTable("Details");
adpt.Fill(dt);

but this time howcan i fill the xml dy using this datatable


Any one please send your valueble suggestions and if you have any code or relatedlinks please send me
Jun 9 '08 #1
3 1178
Curtis Rutland
3,256 Expert 2GB
As far as I know, there are no built in methods to do this for you. You'll have to do it the hard way.

Here's a pretty good starter tutorial on creating an XML document with C#. Google search "c# xml" for more.

You'll just have to modify the tutorial code to loop through your datatable.
Jun 9 '08 #2
Plater
7,872 Expert 4TB
What do you mean by "fill the xml"?
DataTables have a .WriteXML() function, does that help?
Jun 9 '08 #3
Curtis Rutland
3,256 Expert 2GB
What do you mean by "fill the xml"?
DataTables have a .WriteXML() function, does that help?
Totally forgot about that. That is a built in, easy way. Like, three lines of code easy.
Jun 9 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Seiche V via DotNetMonster.com | last post by:
hy. i want to fill a data table from a dataset using SqlDataAdapter.fill(myTable), but i get the error: System.NullReferenceException: Object reference not set to an instance of an object. ...
4
by: Manuel | last post by:
I'm using a typed dataset and would like to retrieve a specific table but filtering the rows returned (no point in getting more than what you need, right?). The problem is that the .Fill method of...
10
by: dauphian | last post by:
Hello, I am new to .net and am trying to build a report application that queries 4 different tables based on a id, and I need to return them in the same table for easy viewing. Basically, I...
2
by: MDB | last post by:
Hello All, I have a data grid that I fill using a dataset. The results of the query has around 15 columns and 500 rows (and growing). The reason I am using the datagrid is so the end users can...
0
by: dalaeth | last post by:
I have searched Google high and low and haven't found anything that works. Here's my problem, hopefully someone will be able to help! I'm using 1.1 Framework, and ODP.NET 9.5.0.7 on a Windows...
2
by: Adrien Reboisson | last post by:
I'm trying to build a basic DB explorer using C# & Visual Studio 2005. I installed SQL Server 2005 Express, created a blank project, dropped a TreeView, a ListView and a DataGridView : DB objects...
0
by: mike1402 | last post by:
Hi ! I get the error below sometimes when retrieving a big amount of data using Datadapter.Fill(dataset,"table"). But when I send the command Fill again, there is no error. Is it a fault of...
2
by: Ryan Liu | last post by:
Hi, If I have a very big view in database, it covers 15 tables, each table has 1000 columns. When I issue select * from view, the database will give error -- too many columns. Can I use a...
1
by: David | last post by:
Hi, Using .NET 1.1, C# I am using a provider factory so that my app can use various database types. I am currently using the DataAdapter from the provider to fill a dataset, however, I...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.