WebService ASP.NET C#

metroxamensa

New Member
Hey, I have created a WebMethod in a WebService that uses stored procedures to find whatever you are searching for.\[code\][WebMethod]public DataSet getMyData(string search){ using (SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True")) { conn.Open(); SqlCommand cmd = new SqlCommand("searchingads", conn); SqlDataAdapter da; DataSet ds = new DataSet(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@search", search); da = new SqlDataAdapter(cmd); da.Fill(ds, "MyData"); conn.Close(); conn.Close(); return ds; }\[/code\]I don't know how to call this method from an ASP.NET application. I have a button that, when clicked, needs to call this method and populate a GridView.I have the following code in my ASP.NET web application (on button click):\[code\]WebService1 service = new WebService1();GridView2.DataSource = service.IskanjeOglasov(TextBox1.Text);GridView2.DataBind();Label1.Text = service.HelloWorld();\[/code\]The label switches to "hello world" when the button is clicked, but it doesn't give me any table when I do a search.Thank you in advance for your help.
 
Back
Top