Solved

Use a WEB service to populate a foreach loop?

Posted on 2006-11-14
6
232 Views
Last Modified: 2010-04-16
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;Integrated Security=True";
            SqlDataAdapter da = new SqlDataAdapter(strCmd, m_connString);
            DataSet ds = new DataSet();
            da.Fill(ds, "Attachments");

            foreach (DataRow row in ds.Tables["Attachments"].Rows)
            {
                string html = "<div title='" + row["Attachments_fileName"] + "' myAttrSrc='" + row["Attachments_URL"]
                + "'onmouseover=\"this.style.cursor='pointer'\" onclick=\"myOnClick(event,'" + row["Attachments_URL"]
                + "',false)\" ondblclick=\"myOnClick(event,'" + row["Attachments_URL"] + "',true)\">&nbsp;" + 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.displayAttachments();

Many thanks
Mousemat24
0
Comment
Question by:mousemat24
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:rameedev
ID: 17955130
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
0
 

Author Comment

by:mousemat24
ID: 17964997
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
0
 
LVL 5

Expert Comment

by:rameedev
ID: 17977752
What is the problem in converting the above code into a web service method....?
0
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

Author Comment

by:mousemat24
ID: 17978087
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
0
 
LVL 5

Accepted Solution

by:
rameedev earned 500 total points
ID: 17978231
Well if you remember the previous question you had asked that one does some thing pretty similar to the question you have asked...i mean taking Dataset as parameter and looping through it
0
 

Author Comment

by:mousemat24
ID: 17978602
Thanks rameedev !!! forgot about that example
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question