请大家帮我看下那里有问题:未将对象引用设置到对象的实例
窗体创建事件
public void cartype_Load(object sender, System.EventArgs e)
{
myconn = new SqlConnection ( this.cartype1.cnnstr ) ;
myconn.Open ( ) ;
string sqlstr = "select typeid as 系统代码,name as 车型名称,type as 车型代码 from cartype";
DataSet my = new DataSet("cartype");
SqlDataAdapter mydata = new SqlDataAdapter(sqlstr, myconn);
mydata.Fill(my,"cartype");
myconn.Close();
}
新增记录事迹
private void button1_Click(object sender, System.EventArgs e)
{
mydata.InsertCommand.CommandText="insert into cartype (name,type) values('"+name.Text+"','"+type.Text+"')";
mydata.InsertCommand.Connection.Open();
mydata.InsertCommand.ExecuteNonQuery();
mydata.InsertCommand.Connection.Close();
}
mydata我实力创建过了啊,为什么还会出这样的提示