نوشته شده توسط
amirh_karimifar
میشه اون قسمت از کدتون رو که این ایرائ هست رو بذارید .
این ارور دلایل زیادی داره . یکیش تخصیص ندادن حافظه به متغیر اشاره گره .
مثلا اگه شما دارید یک query می نویسید قبل از استفاده از selectcommand باید این کار رو انجام بدید .
dataadaptor.selectcommand = new command() ;
این کد مربوط میشه به قسمت edite در فرم که وقتی edit می زنیم فرم دیگری باید یاز شود که شامل همان firdname ..... هست.
internal void EditForm(string id)
{
Master m = new Master();
ID_NUMBER = m.ID;
dbobject.connect();
dataadaptor.selectcommand = new command();
string Sql = " select ID from tbl_users "
+ " where first_name=" + txtName.Text.ToString() + " ,"
+ " last_name= " + txtFamily.Text.ToString() + " ,"
+ " student_number= " + txtStudentId.Text.ToString() + " ,"
+ " username= " + txtUser.Text.ToString() + " ,"
+ " password= " + txtPass1.Text.ToString() + ","
+ " Email_address= " + txtEmailAddress.Text.ToString() + ","
+ " univercity_id= " + this.cmbUni.SelectedValue.ToString() + ","
+ " course_id= " + this.cmbCourse.SelectedValue.ToString() + ", "
+ " province_id= " + this.cmbProvince.SelectedValue.ToString() + ","
+ " city_id= " + this.cmbCity.SelectedValue.ToString() + " ,"
+ " year= " + this.cmbYear.SelectedIndex.ToString() + " ";
Sql = id;
id = ID_NUMBER;
DataTable dt = dbobject.getDataTable(dbobject.Execute(Sql));
txtName.Text = dt.Rows[0]["name"].ToString();
txtFamily.Text = dt.Rows[0]["family"].ToString();
txtStudentId.Text = dt.Rows[0]["student_namber"].ToString();
cmbCourse.SelectedValue = dt.Rows[0]["course_id"].ToString();
cmbProvince.SelectedValue = dt.Rows[0]["province_id"].ToString();
cmbCity.SelectedValue = dt.Rows[0]["city_id"].ToString();
cmbUni.SelectedValue = dt.Rows[0]["univercity_id"].ToString();
cmbYear.SelectedIndex = Int32.Parse(dt.Rows[0]["year"].ToString());
txtEmailAddress.Text = dt.Rows[0]["Email_address"].ToString();
}