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
Jeremy Fourman
NA
6
0
Newbie C# - DataSet AddRow (Solved)
Jun 15 2008 2:52 PM
Hello. Fairly new to C# and the DataSet concept.
I have a DataSet MediaDataSet1 that has one table MediaList with 3 columns.
I also have a form that has 3 textboxes and 2 buttons. One button to add the data input from the text boxes. One to output the data in the DataSet to XML. However the output never contains the data. I am not sure what is wrong. Below is the code in it's current state. Any help would be appreciated.
private void button1_Click(object sender, EventArgs e)
{
MediaDataSet1 mDS = new MediaDataSet1();
//DataTable mDT = mDS.Tables["MediaList"];
DataRow mDR = mDS.Tables["MediaList"].NewRow();
mDR["MediaName"] = MediaNameTB.Text;
mDR["MediaType"] = MediaTypeTB.Text;
mDR["MediaLength"] = MediaLengthTB.Text;
mDS.Tables["MediaList"].Rows.Add(mDR);
//mDT.Rows.Add(mDR);
//mDS.AcceptChanges();
}
private void button2_Click(object sender, EventArgs e)
{
MediaDataSet1 mDS = new MediaDataSet1();
mDS.WriteXml("C:\\Documents and Settings\\user003\\My Documents\\testOut.xml");
}
The XML output always only contains this.
<?xml version="1.0" standalone="yes"?>
<MediaDataSet1 xmlns="http://tempuri.org/MediaDataSet1.xsd" />
Many Thanks.
Jeremy
Reply
Answers (
2
)
Update Database with Changes made to the DataGridView
DataGridView Binding with MYSQL Datatable, Where am i wrong??