读书人

来个高手速度3急膜拜大神来吧

发布时间: 2012-06-06 16:44:11 作者: rapoo

来个高手速度3急,在线等。膜拜大神来吧
private void button2_Click(object sender, EventArgs e)
{
try
{
SqlConnection con = dbu.getConnection();
//SqlCommand com = con.CreateCommand();
Productdiscount pd = new Productdiscount();
Serviceinformation si = new Serviceinformation();
if (MessageBox.Show("您确定要导出吗?", "提示",
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
ExportDate ep = new ExportDate();
//ep.dgvOutPutExcel(dataGridView1);
string se = "select sI_serviceName,aD_activityDiscount from tb_activityDiscount ad,tb_serviceInformation si where ad.aD_activityDiscountId=si.sI_serviceInformationId";


DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(se, con);
sda.Fill(ds);
int i = ds.Tables[0].Rows.Count;
MessageBox.Show("ss" + i);
//si.dataGridView1.DataSource = ds.Tables[0];
//int i = ds.Tables[0].Rows.Count;
//MessageBox.Show("ss"+i);

//ep.dgvOutPutExcel(ds.Tables);
ep.dgvOutPutExcel(si.dataGridView1);



}
}
catch (Exception ex)
{
MessageBox.Show("有异常" + ex.Message);
dbu.closeConnection();

}


}
提示我未将对象应用到实力这是什么意思啊
ds你面有数据
si.dataGridView1.DataSource = ds.Tables[0];
就这句有错误

[解决办法]

探讨

不行啊

[解决办法]
断点到那行,看下
si 是否为 null
dataGridView1 是否为 null
ds 是否为 null
[解决办法]
的确,单步调试下就可以了,这个不难的,相信自己可以解决的
[解决办法]
探讨

si.dataGridView1现在就这个为空。

[解决办法]
这不是你的问题,是电脑的问题啊
很明显啊
你把主机放微波炉里中火5分钟,拿出来就好了
[解决办法]
Serviceinformation si = new Serviceinformation();
si.dataGridView1.DataSource = ds.Tables[0];
si.dataGridView1 被new了吗?

读书人网 >C#

热点推荐