Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Fill a combobox from a Stored Procedure

Posted on 2006-11-08
5
Medium Priority
?
479 Views
Last Modified: 2009-07-29
Hi Experts,

I have a combobox that is bound to a stored procedure. The problem is that I can only display one coulmn in the combobox.
I would like to display all the columns the stored procedure returns (4).

SP:

CREATE PROCEDURE [SelectAllSafe]

AS

SELECT     *
FROM         Safe
GO

VB code:

        '-----------------------------------
        Dim sqlConn As New SqlClient.SqlConnection
        sqlConn.ConnectionString = getConnection2()
        sqlConn.Open()
        Dim cmd As New SqlClient.SqlCommand
        Dim DA As New SqlClient.SqlDataAdapter
        Dim ds As New DataSet
        '-----------------------------------

        cmd.CommandText = "selectallsafe"


        cmd.CommandType = CommandType.StoredProcedure
        cmd.Connection = sqlConn
        cmb1_1.DataSource = Nothing

        DA.SelectCommand = cmd
        DA.Fill(ds, "Safe")

        cmb1_1.DataSource = ds.Tables("Safe")
        cmb1_1.ValueMember = "SafeID"
        cmb1_1.DisplayMember = "SafeNavn"
0
Comment
Question by:jonastovsen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Expert Comment

by:Praveen Kumar
ID: 17898542
It is good to change your Stored Procedure and send one extra column, which is cancatinated all values.
SQL Looks like:

Select Name, Phone, Address, Name + Phone + Address As 'All' From Table
0
 
LVL 13

Accepted Solution

by:
newyuppie earned 1000 total points
ID: 17898679
or create your own multi column combobox with databinding capabilitites.
luckily, this great article by Eric Moreau already explains and provides the source code on how to do this:
http://www.utmag.com/wconnect/wc.dll?9,7,10,772
0
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 17898743
Or get a 3rd party control that has multi-column support in comboboxes (like http://www.infragistics.com).  The first two posted solutions are a lot cheaper and easier though :)
0
 
LVL 8

Expert Comment

by:doobdave
ID: 17905640
..or use a datagrid control
0
 

Author Comment

by:jonastovsen
ID: 17913334

Hi,

Thank you for your time!

Unfortunately, none of the answers solved my problem. However, I will give the points to newyuppie for an interesting article.

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question