在c#中引入了
using
System.Data.Sqlclient;
private void Form1_Load( object sender, System.EventArgs e)
{
SqlConnection cn = new Sqlconnection( " Server=(local); Database=NorthWind;Uid=sa " );
SqlCommand cmd = new SqlCommand( " select * from dbo.Employees " ,cn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds, " Employees " );
dataGrid1.DataSource = ds.Tables[ 0 ].DefaultView;
// dataGrid1.SetDataBinding(ds,"Employees");
}
窗体加载中,出现异常,说 da.Fill(ds, " Employees " ); 未处理的“System.ArgumentNullException”类型的异常出现在 system.data.dll 中。
其他信息: 值不能为空。
以前这种情况写代码的时候不回出错,但最近一键还原了系统,就边成不行了,还有在读取数据库的时候 SqlDataReader
也是不能,真是郁闷死了....请高手帮忙解决掉我这心头只痛,在此谢过.....
private void Form1_Load( object sender, System.EventArgs e)
{
SqlConnection cn = new Sqlconnection( " Server=(local); Database=NorthWind;Uid=sa " );
SqlCommand cmd = new SqlCommand( " select * from dbo.Employees " ,cn);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(ds, " Employees " );
dataGrid1.DataSource = ds.Tables[ 0 ].DefaultView;
// dataGrid1.SetDataBinding(ds,"Employees");
}
窗体加载中,出现异常,说 da.Fill(ds, " Employees " ); 未处理的“System.ArgumentNullException”类型的异常出现在 system.data.dll 中。
其他信息: 值不能为空。
以前这种情况写代码的时候不回出错,但最近一键还原了系统,就边成不行了,还有在读取数据库的时候 SqlDataReader
也是不能,真是郁闷死了....请高手帮忙解决掉我这心头只痛,在此谢过.....
请能帮得上忙的尽管各抒己见,谢谢了,.....