Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 30th, 2004, 06:40 PM
Registered User
 
Join Date: Sep 2004
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();
da.Fill(ds);
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:
System.Data.DataViewManagerListItemTypeDescriptor
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
 
Old October 2nd, 2004, 08:04 AM
Registered User
 
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

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

hope this helps.

 
Old October 9th, 2004, 11:30 PM
Friend of Wrox
 
Join Date: Feb 2004
Posts: 177
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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





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





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