Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
using System;
using System.Data;
using System.Web.Services;



public partial class ReportUI : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Show_Report(object sender, EventArgs e)
    {
        ShowData();
    }

    private void ShowData()
    {
        string ReportName = txtReportName.Text;
        string DatasourceID = txtDataSourceID.Text;

        WebService data = new WebService();
        DataSet allData = new DataSet();

        allData = data.GetResultThroughQuery(ReportName, DatasourceID);
    }
}


C#
 using System;
using System.Linq;
using System.Web.Services;
using System.Collections.Generic;

using System.Data;
using System.Data.SqlClient;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class Service : System.Web.Services.WebService
{
    String ConStr = "Server=192.168.241.2; Database=BIModel; User Id=Sa; password=Nopass123";
   
    
    public Service () {
        
        
                       }


    [WebMethod]
    public DataSet GetResultThroughQuery(string ReportName, string DatasourceID)
    {
        DataSet dataSet=new DataSet();



        return dataSet;
    }
    
}



We get a error message like that: 'System.Web.Services.WebService' does not contain a definition for 'GetResultThroughQuery' and no extension method 'GetResultThroughQuery' accepting a first argument of type 'System.Web.Services.WebService' could be found (are you missing a using directive or an assembly reference?)
Posted
Updated 16-Feb-14 23:37pm
v4

1 solution

Have you inserted service refrence in your solution ?
If not add to your solution and make change in webconfig file as
eg:
my webservice method:
C#
[WebMethod]
       public int insertRecord( string sName, string sAge, string sSalary, string sCountry, string sCity)
       {
           var con = new SqlConnection(ConnectionState());
           con.Open();

           var cmd = new SqlCommand("Insert into EMaster(Name,Age, Salary, Country,City) values( '" + sName + "','" + sAge + "','" + sSalary + "','" + sCountry + "','"+ sCity + "')", con);
           int row = cmd.ExecuteNonQuery();
           return row;
       }


and web.config:

XML
<applicationSettings>
  <EmployeeDetails.Properties.Settings>
   <setting name="EmployeeDetails_localhost_Service1" serializeAs="String">
    <value>http://localhost:50656/Service1.asmx</value>
   </setting>
  </EmployeeDetails.Properties.Settings>
 </applicationSettings>


and in code behnd files use like this

protected void Addbutton_Click(object sender, EventArgs e)
      {
          txtid.Enabled = false;
          localhost.Service1 dbws = new localhost.Service1();
          if ((txtName.Text == "") || (txtage.Text == "") || (txtsalary.Text == "") || (txtcountry.Text == "") || (txtcity.Text == ""))
          { Response.Write("<script>alert('Record not insert-Rows Cannot be null');</script>"); }
          else
          {
              int row = dbws.insertRecord(txtName.Text, txtage.Text, txtsalary.Text, txtcountry.Text, txtcity.Text);
              if (row > 0)
              {
                  Response.Write("<script>alert('Record insert successfuly');</script>");
                  txtid.Text=txtName.Text = txtage.Text = txtsalary.Text = txtcountry.Text = txtcity.Text = "";
                  getId();
                  FillGrid();
                  ddlSelect_SelectedIndexChanged(sender, e);

              }
              else { Response.Write("<script>alert('Record not insert');</script>"); }
          }

      }



here service1 is my webservice name.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900