c# - SQL query runs, but not producing any results -


i have following query display student data in datagridview, doest seems display records @ all. code:

public void setsql() {     string connstr = "provider=microsoft.ace.oledb.12.0;data source=c:\\users\\jasper\\desktop\\autoreg\\autoreg.accdb;";      oledbconnection myconn = new oledbconnection(connstr);     myconn.open();      dataset ds = new dataset();      //query ask     string query = "select * student";      using (oledbcommand command = new oledbcommand(query, myconn))     {         using (oledbdataadapter adapter = new oledbdataadapter(command))         {             adapter.fill(ds);             datagridview1.datasource = ds;             myconn.close();         }     } } 

edit: after seeing comment noticed error. assuming web application.

you should use datatable data source, not dataset. set data source property first table in dataset's tables collection.

in truth, can use dataset, it's not straightforward. allow user change table she's seeing, though.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -