Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

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.

 

  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

Edited by Jay1b
Posted (edited)

Yeah i've tried that as well using the following code:

 

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.

Edited by Jay1b

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...