Wednesday, March 7, 2012

An DatasetMethod

I have a dataset. And I have made 2 methods extra..DeleterQuery(@.id) and the oter one is UpdateQuery(@.naam,@.tussenvoegsel,@.achternaam,@.adres).

My question is how can I get one of these methods at an button and inputbox or something??

Hi khalidelmeknesi ,

Frist question, what are those 2 methods, are they stored procedures or something (well, they looks like stored procedures)? And if it's table adapter functins, you can call it just like any other build-in table adapter functions (e.g. update, getdata,insert...etc) after you have instantialized the tableadapter.

My question is how can I get one of these methods at an button and inputbox or something??

Not sure what you mean by this. But in case if you mean you want to call those 2 stored procedure in your button click event handler, I think it should be easy to implement. For example:

protected void Button1_Click(object sender, EventArgs e) {using (SqlConnection con =new SqlConnection(your_connectionstring_here)) { SqlCommand cmd =new SqlCommand(method_name, con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@.your_parameters", Parameter_value); //I guess maybe you mean the parameter value comes from inputbox in your webpage, right? con.Open(); cmd.ExecuteNonQuery(); } }
Hope my suggestion helps

No comments:

Post a Comment