Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Loading A Combobox - With Code
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Loading A Combobox - With Code
Divers
Thread ID:
00765655
Message ID:
00765655
Vues:
62
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform