Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Fill a combobox from a Stored Procedure

Posted on 2006-11-08
5
Medium Priority
?
482 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
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses

916 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