Wednesday, March 28, 2012

How to assign SQL query to Button in asp.net 2.0

Hi

My webpage contain three dropdown box and one button. One dropdown to choose hospital_id, second dropdown to choose project_id and third dropdown to choose version_no .After choosing these three and when the button is clicked i want to run this sql query

INSERT INTO version(project_id,hospital_id,date_created,comments) SELECT project_id,hospital_id,date_created,comments FROM version whereversion_no=@.version_no andproject_id=@.project_id andhospital_id=@.hospital_id.

Just i need the code in asp.net 2.0 , VB , when the button is clicked the above query should run and the parameters (values) should take from dropdown box.

Could anyone please send the solution for the above problem.

write the query like this

Dim sQuery as String = "INSERT INTO version(project_id,hospital_id,date_created,comments) SELECT project_id,hospital_id,date_created,comments FROM version whereversion_no=" + ONE_DropDown.SelectedValue + "andproject_id=" + Second_DropDown.SelectedValue + "andhospital_id=" +THIRD_DropDown.selectedValue

Try this query

No comments:

Post a Comment