Reading Data from XML and storing them into SQL Database I am developing a C# Windows forms application. In that, I am reading data from XML which is coming from a web API and storing that XML data into SQL database. I am able to achieve this. But my only concern is, In Production environment, this application will be in service and there will a lot of data to synchronize from XML to SQL Database. So, can anyone review my code and tell me whether it is an efficient way or not. Any sugggestions are welcome.

Because it's the first time I am working on the API and even in coding, I am a fresher.

I have done all to achieve my requirement. I would like a code review from experts.

public void save_vendor_info()
    {
    SqlConnection con = new SqlConnection(@"server=localhost;Database=TEST;integrated security=true");
    con.Open();
    DataTable dt = new DataTable();
    XmlDocument doc = new XmlDocument();
    doc.Load("https://testdata/api/vendordata");

    try
    {
        XmlNode node = doc.DocumentElement.ChildNodes.Cast&lt;XmlNode&gt;().ToList()[0];
        foreach (XmlNode column in node.ChildNodes)
        {
            dt.Columns.Add(column.Name, typeof(String));
        }

        XmlNode Filas = doc.DocumentElement;
        foreach (XmlNode Fila in Filas.ChildNodes)
        {
            List&lt;string&gt; Valores = Fila.ChildNodes.Cast&lt;XmlNode&gt;().ToList().Select(x =&gt; x.InnerText).ToList();

           SqlCommand cmd = new SqlCommand(("IF NOT EXISTS (Select Vendorcode From Vendors where Vendorcode = @Vendorcode) INSERT INTO Vendors VALUES (@Vendorcode, @STCD3, @Name1, @Name2, @Name3, @street1, @street2, @street3, @city1, @city2, @city3, @state1, @state2, @state3, @zip1, @zip2, @zip3, @countrycode, @BussinessUnitId, @VATID, @nationalVATID, @IBAN, @BankAccount, @BankCode)"), con);
            cmd.CommandType = CommandType.Text;
            cmd.Parameters.AddWithValue("@Vendorcode", Valores[0]);
            cmd.Parameters.AddWithValue("@STCD3", Valores[1]);
            cmd.Parameters.AddWithValue("@Name1", Valores[2]);
            cmd.Parameters.AddWithValue("@Name2", Valores[3]);
            cmd.Parameters.AddWithValue("@Name3", Valores[4]);
            cmd.Parameters.AddWithValue("@street1", Valores[5]);
            cmd.Parameters.AddWithValue("@street2", Valores[6]);
            cmd.Parameters.AddWithValue("@street3", Valores[7]);
            cmd.Parameters.AddWithValue("@city1", Valores[8]);
            cmd.Parameters.AddWithValue("@city2", Valores[9]);
            cmd.Parameters.AddWithValue("@city3", Valores[10]);
            cmd.Parameters.AddWithValue("@state1", Valores[11]);
            cmd.Parameters.AddWithValue("@state2", Valores[12]);
            cmd.Parameters.AddWithValue("@state3", Valores[13]);
            cmd.Parameters.AddWithValue("@zip1", Valores[14]);
            cmd.Parameters.AddWithValue("@zip2", Valores[15]);
            cmd.Parameters.AddWithValue("@zip3", Valores[16]);
            cmd.Parameters.AddWithValue("@countrycode", Valores[17]);
            cmd.Parameters.AddWithValue("@BussinessUnitId", Valores[18]);
            cmd.Parameters.AddWithValue("@VATID", Valores[19]);
            cmd.Parameters.AddWithValue("@nationalVATID", Valores[20]);
            cmd.Parameters.AddWithValue("@IBAN", Valores[21]);
            cmd.Parameters.AddWithValue("@BankAccount", Valores[22]);
            cmd.Parameters.AddWithValue("@BankCode", Valores[23]);

            cmd.ExecuteNonQuery();
        }
    }
    catch (Exception ex)
    {

    }
}
Review

Single responsibility principle
Method save_vendor_info (which we'll rename later) does data retrieval from an external source, xml to db mapping, and SQL command execution on a database. I would expect a method with the name Save* to only store data, in this case in the database. I would also suggest to split up loading the input data and saving to the database in separate methods. A mediator method could then call both methods and ensures the data is mapped correctly.



Resource management
You don't dispose of resources that you create. SqlConnection and SqlCommand implement the IDisposable interface. You should make sure to dispose these instances (SQL Disposable Pattern Example). You already open the connection before retrieving the web data. This is too soon. Keep the scope of a connection lifetime to a minimum.



Exception Handling
Definining an empty catch block is really bad practice. You don't know whether something went wrong. At least, log exceptions. Think about which specific exceptions you want to handle and which ones need to be propagated up the stack. Even in sand-box mode, where you don't want exceptions to reach the caller, you should return a boolean to the caller whether the call succeeded.



Naming &amp; Style Conventions  


Try to avoid underscores in method names and use PascalCase. Prefer SaveVenderInfo over save_vendor_info. As indicated earlier on, I would use this method name only for the part where you save the data to the database.  
Use var when the type is inferred and don't use abbreviations for variable names: Prefer var dataTable = new DataTable(); over DataTable dt = new DataTable();.
Read SQL connection string information from a config file rather than hardcoding it. This gives better maintainability for different environments.
Be consistent in placement of curly braces. Either append an opening curly brace after the method with a white space between, or place the opening curly brace on the next line at the same indentation of the member declaration. Don't indent a curly brace on the next line, this leads to deeply indented code.