mousemat24
asked on
Use a WEB service to populate a foreach loop?
Hi there
Wonder if you guys can help me with a problem? I'm using ASP.NET/C#/VS2005.
I have the following code in my page_load event. As you can see the connection string + the select statement is display. I've created a WEB service that gets all the information I need from a table. How do I use it with the foreach loop? I dont want to use strCmd, m_connString etc, I simply want to use my web service. Here is the code for the web service:
string m_connString;
string strCmd = "SELECT * FROM Attachments";
m_connString = "Data Source=.;Initial Catalog=Handbook;Integrate d Security=True";
SqlDataAdapter da = new SqlDataAdapter(strCmd, m_connString);
DataSet ds = new DataSet();
da.Fill(ds, "Attachments");
foreach (DataRow row in ds.Tables["Attachments"].R ows)
{
string html = "<div title='" + row["Attachments_fileName" ] + "' myAttrSrc='" + row["Attachments_URL"]
+ "'onmouseover=\"this.style .cursor='p ointer'\" onclick=\"myOnClick(event, '" + row["Attachments_URL"]
+ "',false)\" ondblclick=\"myOnClick(eve nt,'" + row["Attachments_URL"] + "',true)\"> " + row
["Attachments_fileName"] + "</div>";
Place.Text += html;
}
ds.CreateDataReader();
========================== ========== ========== ========== =
My web service code is as follows:
WS_Handbook.Handbook_WS deleteMe = new WS_Handbook.Handbook_WS();
deleteMe.displayAttachment s();
Many thanks
Mousemat24
Wonder if you guys can help me with a problem? I'm using ASP.NET/C#/VS2005.
I have the following code in my page_load event. As you can see the connection string + the select statement is display. I've created a WEB service that gets all the information I need from a table. How do I use it with the foreach loop? I dont want to use strCmd, m_connString etc, I simply want to use my web service. Here is the code for the web service:
string m_connString;
string strCmd = "SELECT * FROM Attachments";
m_connString = "Data Source=.;Initial Catalog=Handbook;Integrate
SqlDataAdapter da = new SqlDataAdapter(strCmd, m_connString);
DataSet ds = new DataSet();
da.Fill(ds, "Attachments");
foreach (DataRow row in ds.Tables["Attachments"].R
{
string html = "<div title='" + row["Attachments_fileName"
+ "'onmouseover=\"this.style
+ "',false)\" ondblclick=\"myOnClick(eve
["Attachments_fileName"] + "</div>";
Place.Text += html;
}
ds.CreateDataReader();
==========================
My web service code is as follows:
WS_Handbook.Handbook_WS deleteMe = new WS_Handbook.Handbook_WS();
deleteMe.displayAttachment
Many thanks
Mousemat24
I am a bit confused here...The above code which is in pageload do you want that to be in a Webservice method? or As previoulsy said u need to define your webservice method to take dataset as parameter and you loop through it
ASKER
Hi rameedev
Sorry if I confused you, my question is, I want to convert my code to a web service.
How do I do it?
and how do I consume it
Thanks for replying to my question
mousemat24
Sorry if I confused you, my question is, I want to convert my code to a web service.
How do I do it?
and how do I consume it
Thanks for replying to my question
mousemat24
What is the problem in converting the above code into a web service method....?
ASKER
rameedev
Sorry, but this is kinda of an old question, I gave up as no one answered to this. So I've completly forgotton why I put this in, looking back I beleive it was "define your webservice method to take dataset as parameter and you loop through it"
I dont know how to do it. Thanks rameedev for answering this post.
mousemat24
Sorry, but this is kinda of an old question, I gave up as no one answered to this. So I've completly forgotton why I put this in, looking back I beleive it was "define your webservice method to take dataset as parameter and you loop through it"
I dont know how to do it. Thanks rameedev for answering this post.
mousemat24
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks rameedev !!! forgot about that example