Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 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 July 26th, 2008, 03:52 AM
Registered User
 
Join Date: Jul 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default display Records in ComboBox

            eBankMainSqlCon.DataCon();
            string UsrName = Convert.ToString(comboBox1.Text);

            SqlCommand CmdList = new SqlCommand("spUserList",eBankMainSqlCon.SqlCon);
            CmdList.CommandType = CommandType.StoredProcedure;

            SqlDataReader ReadRdr = CmdList.ExecuteReader();
            while (ReadRdr.Read())
            {
                comboBox1.Text = ReadRdr["UserName"].ToString();
            }
            ReadRdr.Close();


Hi..I want to display all user in my ComboBox1..but it could not work
pls..help me

 
Old July 26th, 2008, 04:25 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

comboBox1.Items.Add(ReadRdr["UserName"]);

Another couple of things to note:

"spUseList" - you should not use the "sp" prefix on stored procedure names - this is a special prefix designed for global stored procedures only and can have an impact on performance.

"ReadRdr" - not the worst variable name I've ever seen but not very helpful, and overly long too. I just tend to use "r" in a situation like this where there is only 1 reader. Much shorter and no more confusing.

/- Sam Judson : Wrox Technical Editor -/
 
Old July 26th, 2008, 04:34 AM
Registered User
 
Join Date: Jul 2008
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank very much now it really works..
again thank you..

GOd blees..


 
Old July 26th, 2008, 05:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:"spUseList" - you should not use the "sp" prefix on stored procedure names - this is a special prefix designed for global stored procedures only and can have an impact on performance.
Not true..... that only applies to the sp_ prefix....

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old July 26th, 2008, 05:28 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Yeah, you got me - but using "sp" kinda indicates that you're not aware of the rule, and are only one step away from using "sp_" - so best to avoid either....

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display 2 fields as a choice in 1 combobox dilipv General .NET 0 March 5th, 2008 07:21 AM
Data Bind ComboBox to display the List Bjay Pro VB Databases 0 July 29th, 2007 02:57 PM
Display data as per combobox item selected yogeshyl Excel VBA 0 July 28th, 2007 06:17 AM
Display 2 fields as one line in the combobox osemollie VB Databases Basics 2 May 17th, 2006 10:22 AM
date display memeber in combobox twaghorn C# 2 July 13th, 2003 10:14 AM





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