Community discussion forum

display item from table to combobox

Tags:
  • 8 months ago

    hello..

    im working with vb.net...

    can u guys help me solve this problem with some sample code

     i want data from table Rate to display at combobox..

    this is my code:

     Private Sub AddArea_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            area = New AflexiArea
            AddRate()

        End Sub

        Sub AddRate()
            area = New AflexiArea
            ReadSqlData("select (id, value) from rate")
            While myReader.Read
                ComboBox1.Items.Add(myReader.GetValue(0))

                Exit While

            End While
            CloseSqlRead()
        End Sub

     but when i running the error msg said "ExecuteReaders required an open and Connection. The Connection current state is closed"
     it's wrong with my code??

    please help me..

    thanks 

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 8 months ago

     hello..

    thanks for ur concent.. 

    im done now... 

    actually no need put exit while 

     Sub AddRate()
            area = New AflexiArea
            ReadSqlData("select value from rate")
            While myReader.Read
                ComboBox1.Items.Add("RM " & myReader.GetValue(0))

            End While
            CloseSqlRead()
        End Sub

    this is the real code..

     

    thanks... 

Post a reply

Enter your message below

Sign in or Join us (it's free).