Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Loading A Combobox - With Code
Message
De
13/03/2003 20:27:29
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00765655
Message ID:
00765656
Vues:
15
Kirk,

Have you verified that ds_AuthDepts.Tables("Departments") does indeed have data in it? If not, then there's your problem. If it does have data, then try setting the Combo's DataSource, etc. after you fill the DataSet.

~~Bonnie


>I have the following code. It calls a stored procedure to load the data for a combobox. Right now I have in the code for a command button. I get no error, but my combobox never fills with data? Thanks for any help. PS. The stored procedure has one parameter. The value for that paramter @UserID is stored in the global variable gnUserID. I have verified that it does have a value.
>
>
>        'Create a Connection
>        Dim Conn As SqlClient.SqlConnection
>        'gcConnString is a public variable in the Globals.vb file
>        Conn = New SqlClient.SqlConnection(gcConnString)
>
>        Dim cmd As New SqlClient.SqlCommand()
>        Dim da As New SqlClient.SqlDataAdapter()
>        Dim ds_AuthDepts As New Data.DataSet()
>        Dim cb As SqlClient.SqlCommandBuilder
>        Dim prm As SqlClient.SqlParameter
>
>        Try
>            cmd = Conn.CreateCommand
>            cmd.CommandText = "ct_lu_AuthorizedDeptsByUsers"
>            cmd.CommandType = CommandType.StoredProcedure
>            prm = cmd.Parameters.Add("@tiuserID", SqlDbType.Int, 16, "UserID")
>            prm.Value = gnUserID
>
>            Me.ComboBox1.DataSource = Me.ds_AuthDepts.Tables("Departments")
>            Me.ComboBox1.DisplayMember = "DeptDesc"
>            Me.ComboBox1.ValueMember = "DeptID"
>
>            da.SelectCommand = cmd
>            da.Fill(ds_AuthDepts, "Departments")
>
>        Catch ex As Exception
>            MsgBox("Error: " & ex.Message)
>        End Try
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform