• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Drop down list populating wierd in .Net

GoingUp

Lifer
I am trying to get a drop down list to populate with the results of an SQL query.

Here is the code.

sql = "SELECT Order_no FROM ORDERS WHERE Cust_no ='" & idtext & "'"
Cmd = New OleDb.OleDbCommand(Sql, Con)

Con.Open()
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

ddorder.DataSource = reader
ddorder.DataBind()
Con.close()

ddorder is a drop down list. the list gets populated, but it is populated by titles such as System.Data.Commom.DBdatarecord

Ideas?

Edit: I just noticed that the form is kicking out an error that no data exists for my query. The datatable is populated. I don't know why it wouldn't find anything. Its wierd cause there will be a number of items in the DD box that is equal to the number of records that should turn up, but the are all titled System.Data.Commom.DBdatarecord
 
Hm...

Try setting the properties

DataTextField and DataValueField.

ddorder.DataTextField = "Order_no"
ddorder.DataValueField = "Order_no"
 
i got it figured out.

here is my new code that works.

sql = "SELECT Order_no FROM ORDERS WHERE Cust_no ='" & idtext & "'"
Cmd = New OleDb.OleDbCommand(Sql, Con)

Con.Open()
reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)

While Reader.Read()

ddorder.Items.Add(reader(0).tostring())

End While
Con.close()
 
Back
Top