web service consumer

hi experts, i have this method of a web service
public DataSet GetSPData(int contactID)
            SqlConnection con;
            SqlCommand cmd;
            SqlDataAdapter adpt;
            DataSet ds = new DataSet();
            string SP = "dbo.ObtenerContacto";
            string connectionStrings = ConfigurationManager.ConnectionStrings["connectStringADW"].ConnectionString;
            con = new SqlConnection(connectionStrings);
            cmd = new SqlCommand(SP, con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@contactID ", SqlDbType.Int, 10).Value = contactID;
            adpt = new SqlDataAdapter(cmd);
            return ds;

this is the result
-<NewDataSet xmlns=""> -<Table diffgr:id="Table1" msdata:rowOrder="0"> <ContactID>995</ContactID> <Title>Ms.</Title> <FirstName>Cathan</FirstName> <LastName>Cook</LastName> <EmailAddress>cathan0@adventure-works.com</EmailAddress> </Table> </NewDataSet>

or view attached

can help me create a web application to consume?
Who is Participating?
Miguel OzConnect With a Mentor Software EngineerCommented:
Check "Creating a Client to Consume Service " section:

In your case your code behind will look like:
ServiceReference2.StockClient sc = new ServiceReference2.StockClient();
Dataset result = sc.GetSPData("Your contact Id goes here");
enrique_aeoAuthor Commented:
i have this error
The request channel timed out while waiting for a reply after 00:00:58.9599405. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.

this is the code
ServiceReference1.ReviewsSoapClient sc = new ServiceReference1.ReviewsSoapClient();
DataSet result = sc.GetSPData(1);

GridView1.DataSource = result;
Miguel OzConnect With a Mentor Software EngineerCommented:
Please answer:
Can you post your web service code?
What VS/SQL server version are you using?
Note: I do not expect a timeout for such a tiny amount of data. How long does the query execute/ web service method?

enrique_aeoAuthor Commented:
I attached the code of a web service
SQL server version is R2
the method returns a single record
enrique_aeoAuthor Commented:
I returned to the test and it worked, it is likely that the sql server service has been stopped. thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.