I cannot figure this one out! I have a database with a table called main categories. I can insert new main categories all I want but when I try to delete them, nothing happens! I've tried two approaches:
1) deleting from the dataset:
Dim deleteMainCat As dsCategories.maincategoriesRow = dsCategories.maincategories.Rows.Find(lstMainCat.SelectedValue)
dsCategories.maincategories.Rows.Remove(deleteMainCat)
daMainCategories.Update(dsCategories.maincategories)
lstMainCat.DataBind()
and
2) deleting using sql
Dim deleteCommand1 As New OdbcCommand("DELETE From maincategories WHERE MaincatID=@MaincatID", connDB)
deleteCommand1.Parameters.Add(New OdbcParameter("@MaincatID", OdbcType.Int))
deleteCommand1.Parameters("@MaincatID").Value = lstMainCat.SelectedValue
connDB.Open()
deleteCommand1.ExecuteNonQuery()
connDB.Close()
daMainCategories.Fill(dsCategories.maincategories)
lstMainCat.DataBind()
but neither one actually changes the database! When I do the first option (deleting using the dataset), it removes the main category from the dataset (so it LOOKS LIKE it worked), but when I open the database, the category is still there! and when I try it just using sql (option 2), it doesn't do anything at all.
I have the same problem with the UPDATE command, exactly the same behavior. WHAT GIVES? Can anyone help?!!!
-SelArom
1) deleting from the dataset:
Dim deleteMainCat As dsCategories.maincategoriesRow = dsCategories.maincategories.Rows.Find(lstMainCat.SelectedValue)
dsCategories.maincategories.Rows.Remove(deleteMainCat)
daMainCategories.Update(dsCategories.maincategories)
lstMainCat.DataBind()
and
2) deleting using sql
Dim deleteCommand1 As New OdbcCommand("DELETE From maincategories WHERE MaincatID=@MaincatID", connDB)
deleteCommand1.Parameters.Add(New OdbcParameter("@MaincatID", OdbcType.Int))
deleteCommand1.Parameters("@MaincatID").Value = lstMainCat.SelectedValue
connDB.Open()
deleteCommand1.ExecuteNonQuery()
connDB.Close()
daMainCategories.Fill(dsCategories.maincategories)
lstMainCat.DataBind()
but neither one actually changes the database! When I do the first option (deleting using the dataset), it removes the main category from the dataset (so it LOOKS LIKE it worked), but when I open the database, the category is still there! and when I try it just using sql (option 2), it doesn't do anything at all.
I have the same problem with the UPDATE command, exactly the same behavior. WHAT GIVES? Can anyone help?!!!
-SelArom