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
peter piper
NA
22
3.8k
reading in xml files from folder
May 25 2015 12:43 PM
The following code writes the single xml file to an sql table.
Can you please show me how to do a foreach so I can read in multiple files from a single directory
private void button1_Click(object sender, EventArgs e)
{
string cs = @"Server=SQLEX\WS19;Database=XML;User Id=sa;Password=;";
using (SqlConnection con = new SqlConnection(cs))
{
DataSet ds = new DataSet();
ds.ReadXml(@"E:\XML\product.xml");
DataTable dt1 = ds.Tables["cats"];
con.Open();
using (SqlBulkCopy bc = new SqlBulkCopy(con))
{
bc.DestinationTableName = "Category";
bc.ColumnMappings.Add("catClass", "types");
bc.ColumnMappings.Add("catDefinition", "description");
bc.ColumnMappings.Add("cattValue", "amount");
bc.WriteToServer(dt1);
}
}
}
Thank you for any assistance or guidance
Reply
Answers (
1
)
operator overloading
How to read file xml dynamically into Listview in C#