• Hi, Here is an exampel.

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Data.SqlClient;

    using System.Xml;

    using System.Data;

    namespace XMLImportToSQL

    {

    public class XMLImport

    {

    //Create a Connectionstring to SQL Server

    // Trust connection (Server=;Database=;Trusted_Connection=True;)

    public static string SQLConn = "Server= Your server;Database= your database;User Id= User namn;Password= Password;"

    public void SaveXmlToSqlServer()

    {

    //Create the XML Document for tranactions

    m_xmld = new XmlDocument();

    //Load the Xml file

    m_xmld.Load(@"C:\XmlFile.xml");

    //Get the list of name nodes

    XmlNodeList financialyears = m_xmld.SelectNodes("/MainNod/Nod");

    //Loop through the XmlNode

    foreach (XmlNode financialyear in financialyears)

    {

    // Get the Costcenter Attribute Value

    id = financialyear.ChildNodes.Item(0).InnerText;

    fromdate = financialyear.ChildNodes.Item(1).InnerText;

    todate = financialyear.ChildNodes.Item(2).InnerText;

    // Update if value has change else Insert new row

    using (SqlConnection conn = new SqlConnection(SQLConn))

    {

    SqlCommand sqlCmdUpdate = new SqlCommand();

    sqlCmdUpdate = new SqlCommand("Update_Insert_Financialyears", conn);

    sqlCmdUpdate.CommandType = CommandType.StoredProcedure;

    sqlCmdUpdate.Parameters.AddWithValue("@id", id);

    sqlCmdUpdate.Parameters.AddWithValue("@fromdate", fromdate);

    sqlCmdUpdate.Parameters.AddWithValue("@todate", todate);

    // Check to see if the state is closed.

    if (conn.State == ConnectionState.Closed)

    {

    // Open the connection.

    conn.Open();

    }

    sqlCmdUpdate.ExecuteNonQuery();

    // Check to see if the state is open.

    if (conn.State == ConnectionState.Open)

    {

    // Open the connection.

    conn.Close();

    }

    }

    }

    }

    }

    }

    Hope this will help you?

    Regads

    Stefan Brand