Monday, July 4, 2016

Fill ComboBox ; SQL Server ; VB.NET

        Try
            myconn = New SqlConnection(My.Settings.testsettings)
            myconn.Open()
            mycmd = New SqlCommand("select * from test1", myconn)
            dr = mycmd.ExecuteReader

            While dr.Read
                ComboBox1.Items.Add(dr("fname"))

            End While

        Catch ex As Exception
            MessageBox.Show(ex.Message, "cbox")

        End Try

        myconn.Close()
        mycmd.Dispose()
        dr.Close()

No comments: