如何修复此错误Null Reference Exception未处理? [英] How to fix this error Null Reference Exception was unhandled?
本文介绍了如何修复此错误Null Reference Exception未处理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个数据库名称: OptiMaint ,
,包含表格名称: < strong style ="margin:0px; padding:0px; border:0px; vertical-align:baseline"> dbo.EQUIPEMENTS ,
I设计了一个带有一些基本信息字段的表格。
I have designed a form with some basic information fields.
我已将表格与SQL Server Management 2008连接
I have connected the form with SQL Server Management 2008
我收到这个名字的错误'空引用异常未处理'
这是我的按钮代码:
this is my button code:
private void ajouter_modifier_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlCommand com = new SqlCommand();
SqlConnection con = new SqlConnection("Data Source=CHAIMA;Initial Catalog=OptiMaint;Integrated Security=True");
DataRow row;
row = ds.Tables["dbo.EQUIPEMENTS"].NewRow();
row[1] = equip.Text;
row[2] = textBox1.Text;
row[5] = textBox2.Text;
row[6] = textBox3.Text;
row[7] = textBox4.Text;
ds.Tables["dbo.TR_EQUIPEMENTS"].Rows.Add(row);
}
请帮忙!
谢谢!
推荐答案
也许有一个约束说第三个字段必须包含一个值或者还有更多七个数据列?
Perhaps there is a constraint on say the third field which must contain a value or are there more than seven data columns?
这篇关于如何修复此错误Null Reference Exception未处理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文