Hi guys how can I insert multiple xml files in one table.
Thanks

Recommended Answers

All 3 Replies

could you provide more information/example? This is really unclear.

i have 3 xml files and i want to insert them in database in one single table . Let me know what you dont understand.

alright guys i got it.below is the way how you can achieve this

string myString = "";
            string sXMLFilePath = "C:\\Dict1.txt";
            XmlDocument document = new XmlDocument();

            document.Load(sXMLFilePath);
            XmlNodeList nodelist = document.SelectNodes("ArrayOfString/string");
            SqlConnection cn = new SqlConnection(@"Server=208.124.179.197;Database=RTLUser;UID=sa;");
            SqlDataAdapter da = new SqlDataAdapter();

            cn.Open();
            foreach (XmlNode node in nodelist)
            {
                string coll = node.InnerText.Replace("'","''");
                myString = @"INSERT INTO levelTbl(word,level)  Values('" + coll + "','" + "1" + "')";

                SqlCommand myCmd = new SqlCommand(myString, cn);
                myCmd.ExecuteNonQuery();

            }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.