Najam Sikander Awan

covering web stack along with microsoft technologies

Sql Data Srouce Control Deleting Data From Database

| Comments

Hey guyz today i will show you how to fire delete query by using our beloved control sqldatasource.

Here is the code

1
2
3
4
5
SqlDataSource myDbSource22 = new SqlDataSource();
myDbSource22.ConnectionString = ConfigurationManager.ConnectionStrings["lalConnectionString"].ConnectionString;
myDbSource22.ProviderName = "System.Data.SqlClient";
myDbSource22.DeleteCommand = "delete from ProductsGroups where pid = " + productId;
myDbSource22.Delete();

All it does it deletes all the rows for a given productID from table productgroups. Simple right ;)

Comments