|
-
Jan 31st, 2012, 10:33 AM
#1
Thread Starter
Member
Deleting from a database using treeview
Hey all, I need some help deleting data from a database using a treeview. What I mean is that I have a treeview that is generated from a DB, I want to give the user the option of deleting right from the treeview by selecting the node and the clicking the delete button. I have three different treeviews, but they do share links, so i have 3 different buttons set up and have different code set up based on which event is triggered. The code is basically the same throughout but each one, but based on the level they may have more to delete.
Code Example: this is the aspx.vb code
Dim ControlID As Int32 = CInt(tvADMSInfo.SelectedNode.Value.ToString())
Common.DeleteScreen(ControlID)
Dim HelpLinkID As Int32 = CInt(tvHelpContents.SelectedNode.Value.ToString())
Common.DeleteLink(HelpLinkID)
Dim HelpContentID As Int32 = CInt(tvContent.SelectedNode.Value.ToString())
Common.DeleteContent(HelpContentID)
PopulateList()
Also have this in the App_Code, Common.VB file
Public Shared Function DeleteScreen(ByVal ControlID As Int32) As Boolean
Try
Dim CS As String = System.Configuration.ConfigurationManager.ConnectionStrings("CS").ToString
Dim oParams(1) As OracleParameter
oParams(0) = New OracleParameter("return", OracleDbType.Int32, ParameterDirection.ReturnValue)
oParams(1) = New OracleParameter("p_ad_help_link_id", OracleDbType.Int32, ParameterDirection.Input)
oParams(1).Value = ControlID
OracleHelper.ExecuteNonQuery(CS, CommandType.StoredProcedure, "ad_help.deletescreen", oParams)
If CInt(oParams(0).Value) = 1 Then
Return True
Else : Return False
End If
Catch ex As Exception
Return False
End Try
End Function
Once the event is trigger the aspx.vb code runs, and sends the data to the common.vb which then sends that data to a PL/SQL page which runs the PL/SQL, this code is pretty simplistic.
What happens is either it deletes the wrong data, or nothing at all, it runs the code, but will not throw any errors, just says done. It seems that if I only have one piece of data in the DB it works fine, but does not run though the code completely, will delete the first piece of data then just does nothing, also i can not go in to other 2 delete events i have and delete the data cause it just runs the code and reloads the page without deleting anything. Thanks for any help you guys can provide
-
Feb 1st, 2012, 12:28 AM
#2
Re: Deleting from a database using treeview
show us the ad_help.deletescreen USP
__________________
Rate the posts that helped you 
-
Feb 1st, 2012, 03:20 PM
#3
Re: Deleting from a database using treeview
Hello,
In these sorts of situations, you have to break it down, and figure out at which part the system isn't working as intended.
The place to start is at the database. Make sure that by calling each of your stored procedures, with data that it is expecting, works exactly as you intended it to. That way, you know that, if called correctly from ASP.Net, the stored procedures will do what is needed.
Once you have done that, you can start to debug your code, knowing that it must be something here that is causing the problem.
Step into the code, making sure that when you call the stored procedure, they are getting the parameters that you expect from your treeview. If this is not the case, then you have to debug earlier in the method calls, to see what isn't working as expected.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|