3

I created a simple webservice in C# that returns a table with all the values which is called from a SQL Stored Procedure. I need a little help I wanted to implement a search Textbox for my datagridview in my windowsform application. How could I pass the @search in the storedprocedure to my windows application and send the value back to the stored procedure? Also if I am approaching this the wrong way please let me know Thanks.

    SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ORCA"].ToString());

    SqlCommand cmd = new SqlCommand("usp_getcardinfo", connection);
    cmd.CommandType = System.Data.CommandType.StoredProcedure;

As of right now this populates the datagridview just fine. Would like to get it so you can search and that record displays in the datagridview.

Thanks

1 Answer 1

1

Change your web method into parameter

[WebMethod] 
public List<clubmembers> GetClubMembers(String search)

add statement before try catch

SqlParameter paramSearch = new SqlParameter ("@search",SqlDbType.VarChar);
paramSearch.Value = search;
cmd.Parameters.Add(paramSearch);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.