Solved

ComboBox won't populate by stored procedur with parameter. Need someone to check code.

Posted on 2013-12-21
2
395 Views
Last Modified: 2013-12-21
Hello,
same as title question. I would be pleased if someone show me, why my code won't popualte combobox by sql stored procedure.

 Dim newAdapater As SqlDataAdapter
                Dim tbl As New DataTable
                Dim conProc As New SqlConnection
                Dim cmdProc As New SqlCommand
                conProc.ConnectionString = DB
                conProc.Open()
                cmdProc.Connection = conProc
                cmdProc.CommandText = "GetState"
                cmdProc.CommandType = Data.CommandType.StoredProcedure
                cmdProc.Parameters.Add("IsoCodes", Data.SqlDbType.NVarChar, 500).Value = "US"
                newAdapater = New SqlDataAdapter(cmdProc)
                newAdapater.Fill(tbl)
                Me.ComboBoxState.DataSource = tbl
                Me.ComboBoxState.DisplayMember = "StateName"

Open in new window


Thank you in advance for help.
0
Comment
Question by:dejandejanovic
[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
2 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39733913
Hi dejandejanovic;

The code looks fine. I tested it in a new project and it worked. I had only changed things with the database I am using such as, connection string,  CommandText, parameter name, parameter value and DisplayMember name and it did fill the ComboBox.

Did you receive any error message?
0
 

Author Closing Comment

by:dejandejanovic
ID: 39734136
Ok, yes code is working. I'm leaveing this post for other members ot help with it.

Mistake was really dummy, so I would not comment.

Thanks for quick reply, and test on your site.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

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