473,624 Members | 2,245 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 1724
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
9404
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
6220
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
3315
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
2687
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
2084
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
1207
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
1772
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
1249
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
3190
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
8233
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
8170
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
8675
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
8619
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...
1
8334
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4078
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...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.