c# - DataSet, SqlDataAdapter, Multiple select returns one table -


i make 1 call (containing several select statement) database , databind results multiple components.

i'm using dataset , sqldataadapter fill tables bound components.

problem results of first select statement put both tables "'system.data.datarowview' not contain property..." error when try use second lot of data on second component.

have misunderstood how meant work?

dataset ds = new dataset();  sqlconnection connection = new sqlconnection(configurationmanager.connectionstrings["mystring"].connectionstring);  stringbuilder topicdropdownlistsql = new stringbuilder(); topicdropdownlistsql.append("select topic.topic_id, topic.topic_title fpl2012_topic topic topic.topic_isenabled = 1;"); topicdropdownlistsql.append("select explain.itemexplanationtype_id, explain.itemexplanationtype_type fpl2012_item_explanation_type explain;");  sqldataadapter da = new sqldataadapter(topicdropdownlistsql.tostring(), connection);  ds.tables.add("topics"); ds.tables.add("explaintype");  ds.enforceconstraints = false;  ds.tables["topics"].beginloaddata(); da.fill(ds.tables[0]); ds.tables["topics"].endloaddata();  ds.tables["explaintype"].beginloaddata(); da.fill(ds.tables[1]); ds.tables["explaintype"].endloaddata();  topicdropdownlist.datavaluefield = "topic_id"; topicdropdownlist.datatextfield = "topic_title"; topicdropdownlist.datasource = ds.tables["topics"]; topicdropdownlist.databind();  explanationtypedropdownlist.datavaluefield = "itemexplanationtype_id"; explanationtypedropdownlist.datatextfield = "itemexplanationtype_type"; explanationtypedropdownlist.datasource = ds.tables["explaintype"]; explanationtypedropdownlist.databind();  connection.close(); 

you can use acces tables there indexes not there names

 dataset ds = new dataset();  sqlconnection connection = new sqlconnection(configurationmanager.connectionstrings["mystring"].connectionstring);  string qry="select topic_id,topic_title fpl2012_topic topic_isenabled = 1; select itemexplanationtype_id, itemexplanationtype_type fpl2012_item_explanation_type ";  sqldataadapter da = new sqldataadapter(qry, connection);  da.fill(ds)  topicdropdownlist.datavaluefield = "topic_id"; topicdropdownlist.datatextfield = "topic_title"; topicdropdownlist.datasource = ds.tables[0]; topicdropdownlist.databind();  explanationtypedropdownlist.datavaluefield = "itemexplanationtype_id"; explanationtypedropdownlist.datatextfield = "itemexplanationtype_type"; explanationtypedropdownlist.datasource = ds.tables[1]; explanationtypedropdownlist.databind();  connection.close(); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -