Datasource property

  • Thread starter Thread starter MS
  • Start date Start date
M

MS

Does anyone have any idea why the following code doesn't work? I've been
getting some very wierd results and cannot figure out the problem. When I
look at cboFolderType.Items(0).ToString I get "System.Data.DataRowView" and
naturally that is what is displayed in the combo and list boxes. Any
ideas??


strDataSource = "Data Source = \My Documents\sample.sdf"

' create connection to DB

Dim cnCreate As New SqlCeConnection(strDataSource )

strSQL = "SELECT folder_name FROM Folders "

strSQL = strSQL & " ORDER BY folder_name"



daFolderInfo = New SqlCeDataAdapter(strSQL, cnCreate)

'Fill the DataTable password_info within the DataSet dsPasswordInfo

daFolderInfo.Fill(dsFolderInfo, "Folders")

cboFolderType.DataSource = dsFolderInfo.Tables("Folders")

lstFolderType.DataSource = dsFolderInfo.Tables("Folders")
 
You need to set the DisplayMember of the Combo or ListBox as well.

cboFolderType.DisplayMember = "folder_name"
 
Back
Top