Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Button to Delete by Listbox Selection?Button to Delete by Listbox Selection?
Previous
 
Next
New Post
8/10/2007 1:16 PM
 



Presently have a few listboxes pulling data from sql database.
Have a button that will be used for deletion of data with pop-up verification.
Found many tutorials that cover issue of deleting from basic listbox, but not within sql database as well.

Using field name: "ClientName" for display within listbox.
So, I am guessing I would have to focus on two elements:  ClientName and Row Selected

Unclear about proper code for deleting sql data according to row selection of listbox.

What would be easiest?



Feedback always appreciated,

-machina12

 
New Post
8/13/2007 3:54 PM
 



Have been digging around to find the answer myself. Still no luck.  Web tutorials focus on deleting from listbox contents.
As I mentioned, deleting from the listbox's contents is no problem, it's having the code also delete sql data that is the concern.

I have tried modifying sql code to include listbox selection, but still no luck.  I know I am close, I just need some guidance.

Here is what I tried using: 

myCommand.CommandText = "DELETE FROM ModuleName where ClientName = ListBox1.SelectedItem"

Using field name: "ClientName" for display within listbox.
So, I am guessing I would have to focus on two elements:  ClientName and Row Selected

Unclear about proper code for deleting sql data according to row selection of listbox.

What would be easiest?



Feedback always appreciated,

-machina12

 

 
New Post
8/13/2007 4:21 PM
 

myCommand.CommandText = "DELETE FROM ModuleName where ClientName = '" + ListBox1.SelectedItem.Text + "'"

I'd try that line.
One thing I do to test my Generated SQL is to output the SQL before I run it and then test it in a DB manager for any execution errors.

Hope that can help.

 
New Post
8/13/2007 5:03 PM
 



Success!
This code works correctly. I figured it was a small tweak to existing code.
Nevertheless, I appreciate such a timely response.

Have 2 other questions you might be able to answer easily. Thanks again.



Repeating a command without re-writting code under each event?
http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/160092/scope/posts/Default.aspx

Boolean values storing through controller.vb?
http://www.dotnetnuke.com/Community/Forums/tabid/795/forumid/111/threadid/157834/scope/posts/Default.aspx


-machina12

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Button to Delete by Listbox Selection?Button to Delete by Listbox Selection?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out