Data successfully stored in database but no in dataset? Urgent

Jan 25 2010 6:04 PM

Hi all, Below is some of my code:
// DataConfig Class in a class file
class DataConfig
{
        public DS_ETuition ds = new DS_ETuition();
        public DS_ETuitionTableAdapters.tb_CourseTableAdapter daCourse = new E_Tuition.DS_ETuitionTableAdapters.tb_CourseTableAdapter();
}

// Course Class in another class file
class Course
{
public void saveCourse()
{
              E_Tuition.DataConfig dataConfig = new E_Tuition.DataConfig();
           System.Data.DataRow dsNewRow;
           dsNewRow = dataConfig.ds.tb_Course.NewRow();
            dataConfig.ds.tb_Course.NewRow();
            dsNewRow[0] = "1";
           dsNewRow[1] = "Biology";
            dataConfig.ds.tb_Course.Rows.Add(dsNewRow);
            dataConfig.daCourse.Update(dataConfig.ds.tb_Course);
}
}

//Form Load Event
private void frmCourseRegistration_Load(object sender, EventArgs e)
{
            DataConfig DataConfig = new DataConfig();
            DataConfig.daCourse.Fill(DataConfig.ds.tb_Course);
            ResetTextField();
}

// Submit Course Button

private void btnSubmit_Click(object sender, EventArgs e)
{
Course Course= new Course();
Course.saveCourse();
}

In frmCourseRegistration, i have a datagridview that binds with the dataset's table to let me check does the data has insert to the dataset. But after the submit button is click, i close and reload frmCourseRegistration form, the datagridview data is empty (means that the data is not fill into dataset i think) . Then i try to open my sql databse, the data is stois inside my database .So i wondering which part ofmy code goes wrong?
 I think is the syntax "DataConfig DataConfig = new DataConfig(); " , making my dataset all became empty . Or i declare wrongly in DataConfig ? should be public static?  Can anyone help tell me where i goes wrong?

Kind Regards,
TJ

Answers (1)