TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tan Jun Meng
NA
1
0
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
Reply
Answers (
1
)
bdate
How do I?