binding webcontrol to a C# method that produces string with xml data

J

jason

Below code:

1. Is only returning one row.. and Im not sure why.
2. I'd like to bind this result to an asp.net web control like
datalist, but's not working. I guess my confusion is that Im trying to
bind as a class object and not an xml file..
3. finally, I was wondering, is there anyway in .net to bind a web
control directly to webservice that is returning an xml file? How, if
you dont know what the service might render, is this what they refer to
as late binding?


public static string Gogetit()
{
string conn = "Data

Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\xx.mdf;Integrated
Security=True;User Instance=True";
using (SqlConnection connection = new
SqlConnection(conn))
{
connection.Open();
SqlCommand cmd = new SqlCommand("select * from book2 for
xml path", connection);
cmd.CommandType =
CommandType.Text;
XmlReader xr =
cmd.ExecuteXmlReader();
xr.MoveToContent();
return(xr.ReadOuterXml());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top