Solved

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

Posted on 2013-12-21
2
398 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

717 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