System.Data.SqlServerCe.dll中发生了未处理的“System.StackOverflowException”类型异常

时间:2016-05-05 10:22:25

标签: c# localdb

下面的代码给出了datagridview中的输出它以前工作正常,现在它给了我System.Stackoverflow错误

enter image description here

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();
        }
    }

0 个答案:

没有答案