Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 30th, 2004, 06:40 PM
Registered User
Join Date: Sep 2004
Location: Skopje, , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ListBox DataSource

I have this code joined to my button (maybe i need to remove the connection from the event and put above the event code .. let me know if that is misstake:
private void button1_Click(object sender, System.EventArgs e)
string source = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Documents and Settings\\Jugoars\\My Documents\\Visual Studio Projects\\WindowsApplication3\\Fillmark.mdb";
string selection = "SELECT * FROM mytable WHERE naslov IS NOT NULL";
OleDbDataAdapter da = new OleDbDataAdapter(selection , source);
DataSet ds = new DataSet();
this.listBox1.DataSource = ds;

and somehow i succeed to make not crash my app at least but now instead records from my database i'm receiving next message within ListBox after i click the button:
i'm little confused here and hane no idea this message why is standing for ... lol
Nearly i forgot to point out that maybe i could mapPath to the DB location like we do it within VBScript manner in ASP/ASP.NET Data Source=" & Server.MapPath("Fillmark.mdb").... maybe there is some System atribute that could provide maping the path and ensure my DB's location ... thanks in advance

Share what you know, learn what you don't
Reply With Quote
  #2 (permalink)  
Old October 2nd, 2004, 08:04 AM
Registered User
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

You need to tell the listbox what fields in your table to display.

this.listBox1.DisplayMember = "somefieldname";
this.listBox1.ValueMember = "somefieldname";

hope this helps.

Reply With Quote
  #3 (permalink)  
Old October 9th, 2004, 11:30 PM
Friend of Wrox
Join Date: Feb 2004
Location: Bangalore, Karnataka, India.
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts

Also remove the connection to some other part of code like Form_Load or one time event.

It is not how much we do,
but how much love we put in the doing.

-Mother Theresa
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple Listbox values in another listbox terryv Excel VBA 0 June 27th, 2007 07:01 AM
Listbox,Postback and Datasource nichola_x_rose ASP.NET 1.0 and 1.1 Basics 5 March 22nd, 2007 04:13 AM
Arraylist is datasource for listbox. Failing. CharissaJB C# 2005 0 September 14th, 2006 10:33 AM
Object datasource VS DataSource SoftMind BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 4 July 27th, 2006 10:44 PM
I'm back :) Listbox var from listbox MichaelTJ .NET Web Services 2 October 21st, 2003 07:06 PM

All times are GMT -4. The time now is 11:47 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.