2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by sdhawan
0

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

0

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();

            }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.