Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6472029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:17:38+00:00 2026-05-25T06:17:38+00:00

Im trying to read xml into SQL and get an error at the ds.ReadXml(C:\test.xml);

  • 0

Im trying to read xml into SQL and get an error at the “ds.ReadXml(“C:\test.xml”);” line,
any hints as to whats wrong? Thanks

tring connectionString = "Data Source=MyServer\\SQLEXPRESS;Initial Catalog=MyCatalog;Password=xxx;Persist Security Info=True;User ID=xxx";
        DataSet ds = new DataSet();
        DataTable sourcedata = new DataTable();
        ds.ReadXml("C:\test.xml");

        sourcedata = ds.Tables[0];

        using (SqlConnection sqlconn = new SqlConnection(connectionString))
        {
            sqlconn.Open();
            using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlconn))
            {
                bulkCopy.ColumnMappings.Add("ID", "ID");
                bulkCopy.ColumnMappings.Add("user_id", "user_id");
                bulkCopy.ColumnMappings.Add("upload_date", "upload_date");
                bulkCopy.ColumnMappings.Add("userAddr", "userAddr");
                bulkCopy.ColumnMappings.Add("serial_no", "serial_no");
                bulkCopy.ColumnMappings.Add("Mfgr", "Mfgr");
                bulkCopy.ColumnMappings.Add("model", "model");
                bulkCopy.ColumnMappings.Add("description", "description");
                bulkCopy.ColumnMappings.Add("type", "type");
                bulkCopy.ColumnMappings.Add("code", "code");
                bulkCopy.ColumnMappings.Add("comments", "comments");
                bulkCopy.ColumnMappings.Add("qty", "qty");
                bulkCopy.ColumnMappings.Add("condition", "condition");
                bulkCopy.ColumnMappings.Add("location", "location");
                bulkCopy.ColumnMappings.Add("price", "price");
                bulkCopy.DestinationTableName = "Upload";
                bulkCopy.WriteToServer(sourcedata);
            }
        }
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T06:17:39+00:00Added an answer on May 25, 2026 at 6:17 am

    Your C:\test.xml is being read as C:(tab character)est.xml. Put a @ in front of your string: @"C:\test.xml", or escape it with "C:\\test.xml".

    9 times out of ten, you’d get an error message along the lines of ‘illegal escape character’ when you make this mistake and it would be a lot more obvious what’s wrong, but in this case it just happens to be legal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read an XML file into a data set using dataset.ReadXml(fileName,
I'm trying to read a dataset as xml and load it into an XML
So I am trying to read an XML file into a string in Perl
On SQL Server 2008 R2, I am trying to read XML value as table.
Trying to read into an object the following XML file (can be changed) into
I have this XML that I am trying to read into an object hierarchy:
I'm currently trying to read the contents of an XML file into a Map
I'm trying to read a xml file (from facebook) into my page. I keep
I'm trying to read Stanford ecorner XML: open(http://ecorner.stanford.edu/RecentlyAdded.xml) but am running into the following
I'm trying to read an xml file into memory, add a node, then write

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.