Stuck with retrieving values from a listbox

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Alex A via .NET 247 (anonymous_at_dotnet247.com)
Date: 04/30/04

  • Next message: Thomas Jespersen: "Re: Justification of using C# over VB.NET"
    Date: Fri, 30 Apr 2004 13:28:04 -0700
    
    

    Hello all. I'm new to .NET and I am stuck and I just cannot get this to work (even after much searching).

    I have a listbox populated by data from an Access Database. The manner in which I fill the listbox is as follows:

    \\\\\\\\
            dsClosedPos.Clear()

            dbAdapter.SelectCommand = New OleDbCommand
            dbAdapter.SelectCommand.Connection = dbConnect
            dbAdapter.SelectCommand.CommandText = _
                "SELECT * FROM qryClosedOutPositions"
            dbAdapter.SelectCommand.CommandType = CommandType.Text

            dbConnect.Open()
            dbAdapter.SelectCommand.ExecuteNonQuery()
            dbAdapter.Fill(dsClosedPos, "ClosedPos")
            dbConnect.Close()

            lstClosedPos.DataSource = dsClosedPos.Tables("ClosedPos").DefaultView
            lstClosedPos.DisplayMember = "TRADED"
    \\\\\\

    This populates the listbox (lostClosedPos) with the results from the query. I am tryint to retrieve the SelectedValue when a user makes a change. However, using something along the lines of lstClosedPos.SelectedItem.Tostring() or lstClosedPos.SelectedValue does not work. I need the value of the listbox selection as a variable for a query.

    Any help would be appreciated.

    -----------------------
    Posted by a user from .NET 247 (http://www.dotnet247.com/)

    <Id>FD3bt6WkBEWvgpEvqiDgpA==</Id>


  • Next message: Thomas Jespersen: "Re: Justification of using C# over VB.NET"

    Relevant Pages

    • Re: Word 2007 Find command does not respond
      ... helps with Find getting 'stuck'. ... but the find function still doesn't work when I'm searching for a Hebrew ... MS Office System Products MVP ...
      (microsoft.public.word.application.errors)
    • Re: Help required
      ... You need to have a local store. ... It could be either a database (SQL Server or ... even an Access database). ... I am stuck at the point of how do I keep the information, ...
      (microsoft.public.dotnet.languages.vb)
    • Re: Lyrics Only - Stuck in a Fish Tank
      ... > STUCK IN A FISH TANK ... > another sunken ship ... > searching thru the waters ...
      (rec.music.makers.songwriting)
    • Internet Explorer Homepage Restrictions
      ... In fact I was searching for a solution to this ... only my homepage is now "stuck" on ... >I am the administrator. ... Please tell me how to restore ...
      (microsoft.public.windowsxp.security_admin)
    • Re: Trouble Finding a #sign with Find/Replace
      ... missed another chance to use the Replace Function! ... Guess I'm just stuck in my old ways. ... There are several symbols that need the brackets when searching for ... When searching for a symbol, ...
      (microsoft.public.access.gettingstarted)