错误给在con.Open()---对象的一个实例对象参考NotSet会
我的CS代码如下
void sub(Object s, EventArgs e)
{con.Open();
com=con.CreateCommand();
com.CommandText="UPDATE cv SET name = '" + t1.Text.Trim() + "',pass='" + t3.Text.Trim() + "',pdob='" + t5.Text.Trim() + "',mob='" + t6.Text.Trim() + "',psex='" + d1.SelectedItem.Text.Trim() + "',pstatus='" + d2.SelectedItem.Text.Trim() + "',address='" + tax.Value + "',cobj='" + t7.Text.Trim() + "',eque='" + t8.Text.Trim() + "',etype='" + d1.SelectedItem.Text.Trim() + "',eyear='" + t9.Text.Trim() + "',edur='" + t10.Text.Trim() + "',sind='" + d1.SelectedItem.Text.Trim() + "',sjob='" + t11.Text.Trim() + "',scom='" + t12.Text.Trim() + "',sdate='" + t13.Text.Trim() + "',sdur='" + t14.Text.Trim() + "' where email='" + t2.Text.Trim() + "'";
try{
com.ExecuteNonQuery();
System.Web.UI.WebControls.Label lbl1=new System.Web.UI.WebControls.Label();
lbl1.ForeColor=System.Drawing.Color.Yellow;
lbl1.BackColor=System.Drawing.Color.Blue;
lbl1.Text="Your record UPDATED sucessfully";
ph1.Controls.Add(lbl1);
}
catch(Exception ex)
{
Response.Write(ex.Message);
}
con.Close();
}