我尝试使用此代码从ms访问datagridview
写入数据try
{
string strProvider = @"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = Database.accdb";
string strSql = "Select * from Category";
OleDbConnection con = new OleDbConnection(strProvider);
con.Open();
OleDbCommand cmd = new OleDbCommand(strSql, con);
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
dgw.DataSource = dt;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
但我收到了这个错误:
System.NullReferenceException: Object reference not set to an instance of an object.