dotnet Rider
dotnet Rider

Reputation: 9

how to access database from web service?

How to access database from a web service in ASP.NET? i have a [webmethod] in WebServices class and this is not calling in code file:

[WebMethod]
public DataSet Populate(string con, string sql)
{
    DataSet DS = new DataSet();
    SqlConnection conn = new SqlConnection(con);
    SqlDataAdapter DA = new SqlDataAdapter(con, sql);
    DA.Fill(DS);
    Return DS;
}

Upvotes: 0

Views: 1168

Answers (1)

Satinder singh
Satinder singh

Reputation: 10208

Check you sql cmd is not blank. and write as
SqlDataAdapter DA = new SqlDataAdapter(sql,con);

Upvotes: 1

Related Questions