下面的代码给出了datagridview中的输出它以前工作正常,现在它给了我System.Stackoverflow错误
static class SqlFunctions
{
static private SqlCeConnection con = new SqlCeConnection(@"Data Source=|DataDirectory|\bazardb.sdf");
static public void refresh(DataGridView datagrid)
{
try
{
if (con.State != ConnectionState.Open)
{
con.Open();
}
SqlCeDataAdapter dataadapter = new SqlCeDataAdapter("select * from item", con);
DataTable datatable = new DataTable();
dataadapter.Fill(datatable);
datagrid.DataSource = datatable;
}
catch (SqlCeException e)
{
MessageBox.Show(e.ToString());
}
finally
{
con.Close();
}
}