Quantcast
Channel: All Forums
Viewing all articles
Browse latest Browse all 27852

webservice

$
0
0

Hey i have created a webmethod in webservice that uses stored procedures to find whatever you are seraching for.

[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;

            }

I dont know now, how to cal lthis method from asp.net application. There i have a button, when clicked it needs to call this method and populate a gridview.

I have this in my asp web application(onbuttonclicked):

                WebService1 service = new WebService1();
                GridView2.DataSource = service.IskanjeOglasov(TextBox1.Text);
                GridView2.DataBind();

                Label1.Text = service.HelloWorld();
       


The label switches to hello world when button is clicked, but it doesnt give me any table when i do search

Ty for help


Viewing all articles
Browse latest Browse all 27852

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>