Access DB not displaying in DataGridView in C# -
this driving me nuts. i've seen other responses type of question hasn't helped. created simple access db , want display tables in datagrid. i've created similar worked yet when try this, won't display. how can check if connection working? code being used is
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.windows.forms; using system.data.oledb; namespace castock { public partial class form1 : form { public form1() { initializecomponent(); } private datatable dtable = new datatable(); private void form1_load(object sender, eventargs e) { string sqlstr = "select * products"; updatedatagrid(sqlstr); } private void updatedatagrid(string psqlstr) { string connstr = "provider = microsoft.ace.oledb.12.0;" + "data source = stock.accdb"; oledbdataadapter dadapter = new oledbdataadapter(psqlstr,connstr); dtable.clear(); dadapter.fill(dtable); dadapter.dispose(); dgvstock.datasource = dtable; } } }
Comments
Post a Comment