473,854 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can we populate a XML formated string into a dataset?

When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., datset.read(str ing filename), dataset.readxml (string
filename)).

If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David
Mar 29 '07 #1
6 1734
http://www.google.com/search?hl=en&q...+to+dataset%22

There's good info in the links returned by that Google query.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"david" <da***@discussi ons.microsoft.c omwrote in message
news:A2******** *************** ***********@mic rosoft.com...
When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., datset.read(str ing filename), dataset.readxml (string
filename)).

If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David

Mar 29 '07 #2
I have searched Yahoo and Microsoft web, some info seems useful but doesn't
work.

I will try to find some.

David

"Juan T. Llibre" wrote:
http://www.google.com/search?hl=en&q...+to+dataset%22

There's good info in the links returned by that Google query.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"david" <da***@discussi ons.microsoft.c omwrote in message
news:A2******** *************** ***********@mic rosoft.com...
When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., datset.read(str ing filename), dataset.readxml (string
filename)).

If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David


Mar 29 '07 #3
Here's a quick example :

<%@ Import Namespace="Syst em.Data" %>
<script runat="server">
sub Page_Load(sende r as Object, e as EventArgs)
Dim myDataSet as New DataSet()

myDataSet.ReadX ml(Server.MapPa th("some.xml") )

dgSome.DataSour ce = myDataSet
dgSome.DataBind ()
end sub
</script>

<body>
<asp:datagrid id="dgSome" runat="server" />
</body>

If you are getting the XML from a stream,
you'll need to write it to disk before using this method.

That shouldn't present too many complications.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
=============== =============== =====
"david" <da***@discussi ons.microsoft.c omwrote in message
news:81******** *************** ***********@mic rosoft.com...
>I have searched Yahoo and Microsoft web, some info seems useful but doesn't
work.

I will try to find some.

David
"Juan T. Llibre" wrote:
>http://www.google.com/search?hl=en&q...+to+dataset%22

There's good info in the links returned by that Google query.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
============== =============== ======
"david" <da***@discussi ons.microsoft.c omwrote in message
news:A2******* *************** ************@mi crosoft.com...
When I check the syntax of dataset, It seems that dataset can only read data
from file. (e.g., dataset.read(st ring filename), dataset.readxml (string filename)).
If I have a string with XML format that is transfered from somewhere else,
how can I read the string and populate it into a dataset, then display the
data in a data grid?

Thanks for any help.

David

Mar 29 '07 #4
Incase you have yr xml in the form of a string and not a physical .xml file
on the server, in that case you could try this option.

Load the string into an StringReader object and the same can be passed to
the ReadXml method of the dataset.

StringReader strReader = new StringReader(st r);
DataSet _ds = new DataSet();
_ds.ReadXml(str Reader);
Response.Write( _ds.GetXml());

This should work.
Mar 29 '07 #5
Thanks
I will try your stringreader.

David

"Parvathy Padmanabhan" wrote:
Incase you have yr xml in the form of a string and not a physical .xml file
on the server, in that case you could try this option.

Load the string into an StringReader object and the same can be passed to
the ReadXml method of the dataset.

StringReader strReader = new StringReader(st r);
DataSet _ds = new DataSet();
_ds.ReadXml(str Reader);
Response.Write( _ds.GetXml());

This should work.
Mar 30 '07 #6
Thanks for all of you.

StringReader makes the program work.

David

"Parvathy Padmanabhan" wrote:
Incase you have yr xml in the form of a string and not a physical .xml file
on the server, in that case you could try this option.

Load the string into an StringReader object and the same can be passed to
the ReadXml method of the dataset.

StringReader strReader = new StringReader(st r);
DataSet _ds = new DataSet();
_ds.ReadXml(str Reader);
Response.Write( _ds.GetXml());

This should work.
Mar 30 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9416
by: Goldsworth_Systems | last post by:
I have a string containing valid XML. How do I populate a dataset based on the string, without reference to an XML schema or writing the XML to file and reading it back in again?
7
6239
by: Sharon | last post by:
I have successfully loaded a DataSet object with a XML schema (XSD). Now I wish to populate the tables that was created in the DataSet. I have an XML file/string that contain all the needed data in the same format as the XSD (the XML file/string was created using this same schema). The XML file/string may contain data for a single table or for several tables at once. The question is:
9
3329
by: Mike L | last post by:
I tried a sample of code in MSDN magazine, but now I'm stuck. What code has the best performance to populate a Data Grid with a SP? Below is the code I have, which might be completing the wrong way to populate a data grid. I like using code and not the server explorer. (I replaced the sa password for this post.) private void frmDealerSearch_Load(object sender, System.EventArgs e) { string sConnString = "Data
3
2706
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to populate multiple webpages containing customer information. There isn't a one-to-one correlation between the stored procedure and a webpage. In other words, a webpage may have to refer to 1 or more DataTables to populate itself. Therefore, a...
3
2107
by: crjunk | last post by:
I have 4 different databases that I'm having to pull data from in order to populate a datagrid. I am able to do this, but my problem is that because I'm pulling the data from 4 different databases, the data is ordered alphabetically but is grouped by database. Here is an example of what is happening to the data in the datgrid with the code that I have now. DB1 Apple DB1 Bird DB1 Cake
3
1227
by: Paul D. Fox | last post by:
I would like to read from Active Directory and populate a dataset to be passed in a Web Service. I can get the data from AD just fine, but can I populate a dataset with these values and do a "Return dataSetName" in my web service?
16
1789
by: Mike Fellows | last post by:
when i load my windows form i populate a combobox i use the code below Dim conn As New System.Data.SqlClient.SqlConnection(strConn) Dim sql As String = "AllLenders" Dim da As New System.Data.SqlClient.SqlDataAdapter(sql, conn) Dim ds As New DataSet() da.Fill(ds) ComboBox1.DataSource = ds.Tables(0) ComboBox1.DisplayMember = "Lender" da.Dispose()
2
1256
by: paumierj | last post by:
Hi there Here's my question : I'd like to populate a dataset from an XML string, ie: Dim sXmlString As String sXmlString = "<root type='E-Form'><question label='This is my first question'></question><question label='This is my second question'></question></root>
2
3206
by: Tim Kelley | last post by:
Is it possible to populate a grid using code (not binding it to a datasource). Is there something like an additem method? Thanks,
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9751
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11025
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10682
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9513
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5743
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3187
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.