hai to all,
Attribute 'WebMethod' is not valid on this declaration type. It is only valid on 'method' declarations.
my question is how to write the connection string like this web service
public SqlConnection OpenConnection(SqlConnection c)
{
c.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
if (c.State == ConnectionState.Closed)
{
c.Open();
}
return c;
}
**********************************fullcode************************
namespace loginwebservice
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// 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
{
[WebMethod]
SqlConnection con = new SqlConnection();
public SqlConnection OpenConnection(SqlConnection c)
{
c.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
if (c.State == ConnectionState.Closed)
{
c.Open();
}
return c;
}
public DataSet login(string uname, string pwd)
{
OpenConnection(con);
//cmd.Connection = con;
SqlDataAdapter da = new SqlDataAdapter("select * from tbllogin where user_name ='" + uname + "' and password='" + pwd + "' ", con);
DataSet ds = new DataSet();
da.Fill(ds);
return ds;
//con.Close();
}
}
}
thanks in advance.