Filling a Datagrid

Jay1b

Contributor
Joined
Aug 3, 2003
Messages
640
Location
Kent, Uk.
Filling a DROPDOWN box

Could someone please review my code and tell me why i keep getting an error whilst trying to fill the DROPDOWN box?

Thanks.

Visual Basic:
   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim MyConnection As String = "Host=grppc03;Database=bobbert::mv2;User Id=magic;PWD=password;"
        Dim IngresConnection As New IngresConnection(MyConnection)
        IngresConnection.Open()

        Dim CmdString As String = "SELECT * FROM adjust_stock_t"
        Dim IngresCommand As New IngresCommand(CmdString, IngresConnection)

        Dim dr As IngresDataReader
        dr = IngresCommand.ExecuteReader(CommandBehavior.CloseConnection)

        'ddstore is the dropdown box
        ddStore.DataSource = dr 'Error at this line!
        ddStore.DataBind()

    End Sub
 
Last edited:
Yeah i've tried that as well using the following code:

Visual Basic:
 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        Dim MyConnection As String = "Host=grppc03;Database=bobi2::magicv2;User Id=magicdev;PWD=vedjik;"
        Dim IngresConnection As New IngresConnection(MyConnection)
        IngresConnection.Open()

        Dim CmdString As String = "SELECT store FROM inventory_t"
        Dim IngresCommand As New IngresCommand(CmdString, IngresConnection)

        Dim dt As New DataTable
        Dim IAdaptor As New IngresDataAdapter
        iAdaptor.SelectCommand = IngresCommand
        IAdaptor.Fill(dt)

        ddStore.DataSource = dt
        ddStore.DataBind()


    End Sub

Unfortunately i just get a dropdown box full of 'System.Data.DataViewRow' for each record.
 
Last edited:
Back
Top