Problem in DataTable
-
:)In .Net When you Load the Recordset to datatable.If you set source of data to controls like listbox or combobox some times the datas are not viewed instead of In control we see the form of System.Data.DataRowView(It happenes only in sometime not all time )but we can avoid it through dataview For example dim dt as datatable Adapter.Fill(dt) ComboBox.Datasource = dt ComboBox.DisplayMember="Column1" ComboBox.ValueMember = "Column2" // In my case Display member displays record well but problem in Valuemember only i got as system.Data.DataRowView you can avoid this in DirectCasting of DatarowView Otherwise dim dv as dataview = dt.DefaultView ComboBox.Datasource = dv ComboBox.DisplayMember="Column1" ComboBox.ValueMember = "Column2" // Now works fine Otherwise you can directly give as ComboBox.Datasource = dt.Defaultview ComboBox.DisplayMember="Column1" ComboBox.ValueMember = "Column2" // Now works fine I dont know why its happened,If anybody knows ,Let inform here Rugfy Rugfy
-
:)In .Net When you Load the Recordset to datatable.If you set source of data to controls like listbox or combobox some times the datas are not viewed instead of In control we see the form of System.Data.DataRowView(It happenes only in sometime not all time )but we can avoid it through dataview For example dim dt as datatable Adapter.Fill(dt) ComboBox.Datasource = dt ComboBox.DisplayMember="Column1" ComboBox.ValueMember = "Column2" // In my case Display member displays record well but problem in Valuemember only i got as system.Data.DataRowView you can avoid this in DirectCasting of DatarowView Otherwise dim dv as dataview = dt.DefaultView ComboBox.Datasource = dv ComboBox.DisplayMember="Column1" ComboBox.ValueMember = "Column2" // Now works fine Otherwise you can directly give as ComboBox.Datasource = dt.Defaultview ComboBox.DisplayMember="Column1" ComboBox.ValueMember = "Column2" // Now works fine I dont know why its happened,If anybody knows ,Let inform here Rugfy Rugfy
Hi, Check whether ur Column name "Column2" is exactly same as that ur fetching from Databse(I mean check for case sensitivity) Regards, Ritesh
-
Hi, Check whether ur Column name "Column2" is exactly same as that ur fetching from Databse(I mean check for case sensitivity) Regards, Ritesh
:^)Hai, No ritesh,I have checked thats not the problem,I have given details follws Desc Of my Table in DataBase Name Null? Type ----------------------------------------- -------- ------------- OWNERSHIPTYPEID NOT NULL NUMBER DESCRIPTION NOT NULL VARCHAR2(50) MySql Satament cmdLocal = New OracleClient.OracleCommand("SELECT OWNERSHIPTYPEID,DESCRIPTION FROM OWNERSHIPTYPE", Me.conLocal) My Property Binding Of Control Me.DataSource = dtLocal //DataTable Me.DisplayMember = "DESCRIPTION" Me.ValueMember = "OWNERSHIPTYPEID" This code has given problem,But in another cmbobox like this for another table works fine Rugfy