jvcoach23 Posted May 22, 2003 Posted May 22, 2003 I'm trying to bind an sp to a combobox with the dropdown style. I've created a connection and a sqlDataAdapter.. but my code doesn't seem to work... Imports System.Data Imports System.Data.SqlClient Public Class Form3 Inherits System.Windows.Forms.Form Dim myConnection As SqlConnection = New SqlConnection("server=(local);database=dts;uid=sa;password=notwhatImshowing") Dim myAdapter As SqlDataAdapter = New SqlDataAdapter("spPackageName", myConnection) Dim myDS As DataSet Dim WithEvents myDV As DataView Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Me.ComboBox1.DropDownStyle = ComboBoxStyle.DropDown With Me .myDS = New DataSet .myAdapter.Fill(myDS) .myDV = New DataView(myDS.Tables("spPackageName")) .ComboBox1.DataSource = myDS .myConnection.Open() .myConnection.Close() End With End Sub End Class Sql I know.. vb.net I'm just trying to learn. Any help would be great. Quote JvCoach23 VB.Net newbie MS Sql Vet
Administrators PlausiblyDamp Posted May 22, 2003 Administrators Posted May 22, 2003 you will also need to set the ComboBox1.DisplayMember and possibly the .ValueMember Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.