cannot convert void to object

Posted by Pepe under ASP.NET on 10/30/2012 | Points: 10 | Views : 1689 | Status : [Member] | Replies : 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.Services;
using System.Web.Configuration;
using System.Data.SqlClient;
namespace WebService1
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "")]
[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 Service1 : System.Web.Services.WebService

string str1 = WebConfigurationManager.ConnectionStrings["sql1"].ConnectionString;
SqlDataAdapter da;
public WebService1()


public DataSet xx()
SqlConnection conn = new SqlConnection(str1);

string sql = "select STANDARD_UI,ROLE_ID from Test";
da = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
return ds;

in aspx.cs
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
int a;
Product.Service1 ProductsService = new Product.Service1();
GridView1.DataSource = ProductsService.xx(12); GridView1.DataBind();


i m getting error in calling the method xx.. can yu pls help me


Posted by: Krv on: 11/6/2012 [Member] Starter | Points: 25

add the method attribute WebMethod to the xx.

MCTS(SQL Server & BI)

Pepe, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response