c# - DataGridView Not showing Data -


i have following code display data in datagridview table. datagridview empty:

namespace windowsformsapplication5 {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }          private void form1_load(object sender, eventargs e)         {             messagebox.show("sdgds");             sqlcommand scommand;             sqldataadapter sadapter;             sqlcommandbuilder sbuilder;             dataset sds;             datatable stable;             string sql = "select * mytable";             sqlconnection myconnection = new sqlconnection("user id=test;" +                                        "password=test;server=mobile01;" +                                        "trusted_connection=yes;" +                                        "database=mydatabase; " +                                        "connection timeout=30");             myconnection.open();               scommand = new sqlcommand(sql, myconnection);             sadapter = new sqldataadapter(scommand);             sbuilder = new sqlcommandbuilder(sadapter);             sds = new dataset();              sadapter.fill(sds);               sadapter.fill(sds, "mytable");             datagridview1.readonly = true;              datagridview1.selectionmode = datagridviewselectionmode.fullrowselect;             myconnection.close();         }     } } 

because didn't set datagridview.datasource property:

datagridview1.datasource = sds.tables["mytable"]; 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -