Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

809 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