Solved

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

Posted on 2013-12-21
2
390 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
2 Comments
 
LVL 62

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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Calling web service and its methods dynamically 2 41
VB.Net - Windows UserName index and length error 4 22
SQL Server Question 5 25
Sql Query Datatype 2 19
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now