hi every 1. i am trying to bind the combo box through details view in vb.net but unable.
i am making a login form and i want to display two values e.g usertype admin , employee in combobox but when i run the form it doesnot show me anything in combo box although i have selected the true binding source and display member but still unable.
Another problem is in my form load event if i left this line written


it not only shows me the combo box values but also types in the user name and password which is saved in database. All i wana do is when the form gets loaded ..user name and password field should be bland but the user type field should show two values.
kindly help.

What is placed into the dataset will be dependent on what you selected in your SQL statement. If you selected user name and password then they will be included.

Without seeing your code it is hard to provide good help.

hello !
if you want to bind combobox then try this

dim con as new sqlconnection("string")
dim da as new sqldataadapter("your sql query",con)
dim dt as datatable
'now here you can bind your combobox
combobox.databinding.add("selectedvalue",dt,"your database field name",true)
'combobox.databinding.add("selectedvalue",dt,"CityID",true)--like this

If this code solve your prob then please mark your thread solved :)

you can also bind your combobox like this also

//Com is my command, daReserveM my Dataadapter,dtRm1 is my DataTable
        Com.CommandText = "Select ID,RoomType from mytable"
        daReserveM.SelectCommand = Com
        dtRm1.TableName = "mytable"

        drp.DataSource = dtRm1
        drp.DataTextField = dtRm1.Columns(1).ToString
        drp.DataValueField = dtRm1.Columns(0).ToString
//drp is my dropdownlist

Edited 4 Years Ago by pritesh2010: n/a

This article has been dead for over six months. Start a new discussion instead.