server issue when working with different server at the same time
<p>Am working in one Website . In that 2 server is there one is a local server and another one is a main server ..</p>

<p>am doing porting like fetch the data from local server and port into to main server . Main server is a SAP server .. I have to Port the value from Local server to SAP server.. While doing this if network goes down or network disconnected  my porting will be slow down.. and i cant take a back up also ..</p>

<p>can any body help me to solve this problem.. How to over come this problem. </p>

<p>This is My  Web config file ..</p>

<p>This is my Code file through which am going to port </p>

<pre><code>protected void Button1_Click2(object sender, EventArgs e)
{

    // Looping through all the rows in the GridView
    foreach (GridViewRow row in GridView1.Rows)
    {
        CheckBox checkbox = (CheckBox)row.FindControl("chkRows");
        //Check if the checkbox is checked.


        if (checkbox.Checked)
        {
            // Retreive the Product ID
            int productID = Convert.ToInt32(GridView1.DataKeys[row.RowIndex].Value);
            PONO = productID.ToString();
            i++;

            SqlConnection conn1, conn2;

            SqlCommand cmdd2, cmd3, cmd4, cmd5, cmdd1;

            ConnectionStringSettings setting;
            setting = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"];
            string connstring1 = setting.ConnectionString;

            conn1 = new SqlConnection(connstring1);
            conn1.Open();

            cmd4 = new SqlCommand("select Location from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            location = (string)cmd4.ExecuteScalar();

            //cmd4 = new SqlCommand("select PODate from CustOrder where PONO=@PONO", conn1);
            //cmd4.Parameters.AddWithValue("@PONO", PONO);
            //podate = (string)cmd4.ExecuteScalar().ToString();
            podate = DateTime.Now.ToString("yyyy-MM-dd");

            cmd4 = new SqlCommand("select POStatus from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            POStatus = (string)cmd4.ExecuteScalar().ToString();

            cmd4 = new SqlCommand("select Discount from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            dis = (string)cmd4.ExecuteScalar().ToString();

            cmd4 = new SqlCommand("select AfterTaxVal from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            btv = (string)cmd4.ExecuteScalar().ToString();

            cmd4 = new SqlCommand("select CustName from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            CustName = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select CustAddress from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            CustAddress = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select ContactNo from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            ContactNo = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select PINCode from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            PinCode = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select Remarks from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            Remarks = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select LocationCode from Location where LocationName = @LocationName", conn1);
            cmd4.Parameters.AddWithValue("@LocationName", location);
            locationcode = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select LocName from Location where LocationName = @LocationName", conn1);
            cmd4.Parameters.AddWithValue("@LocationName", location);
            locname = (string)cmd4.ExecuteScalar();

            CName = PONO + "-" + CustName;
            POStatus = "Processing";

            CustAdd = CustName + ","+ CustAddress + " PinCode:" + PinCode + " TelNo:" + ContactNo;

            cmd4 = new SqlCommand("select Support from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            Support = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select Catagory from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            Catagory = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select OutletName from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            OutletName = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("select Subsidy from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            Subsidy = (string)cmd4.ExecuteScalar().ToString();

            cmd4 = new SqlCommand("select EmpName from CustOrder where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            EmpName = (string)cmd4.ExecuteScalar();

            cmd4 = new SqlCommand("update CustOrder set POStatus = @POStatus where PONO=@PONO", conn1);
            cmd4.Parameters.AddWithValue("@PONO", PONO);
            cmd4.Parameters.AddWithValue("@POStatus", POStatus);
            cmd4.ExecuteScalar();

            Disc = float.Parse(dis);
            BFT = float.Parse(btv); 
            d = (Disc /(BFT + Disc)) * 100;

            conn1.Close();

            setting = System.Configuration.ConfigurationManager.ConnectionStrings["NewConnectionString"];
            string connstring4 = setting.ConnectionString;
            conn2 = new SqlConnection(connstring4);
            conn2.Open();
            cmd3 = new SqlCommand("insert into OrbERP.dbo.CustInfo values (@DocNum, @CardCode , @CardName, @DocDate , @DocDueDate , @Status , @Discount , @CustName , @CustDet, @BookedBy , @Outlet , @Support , @Catagory , @Capital , @CustAdd , @Remarks, @InvoiceNo, @InvoiceDate, @Value)", conn2);

            cmd3.Parameters.AddWithValue("@DocNum", PONO);
            cmd3.Parameters.AddWithValue("@CardCode", locationcode);
            cmd3.Parameters.AddWithValue("@CardName", locname);
            cmd3.Parameters.AddWithValue("@DocDate", podate);
            cmd3.Parameters.AddWithValue("@DocDueDate", podate);
            cmd3.Parameters.AddWithValue("@Status", "PFB");
            cmd3.Parameters.AddWithValue("@Discount", d);
            cmd3.Parameters.AddWithValue("@CustName", CName);
            cmd3.Parameters.AddWithValue("@CustDet", location);
            cmd3.Parameters.AddWithValue("@BookedBy", EmpName);
            cmd3.Parameters.AddWithValue("@Outlet", OutletName);
            cmd3.Parameters.AddWithValue("@Support", Support);
            cmd3.Parameters.AddWithValue("@Catagory", Catagory);
            cmd3.Parameters.AddWithValue("@Capital", Subsidy);
            cmd3.Parameters.AddWithValue("@CustAdd", CustAdd);
            cmd3.Parameters.AddWithValue("@Remarks", Remarks);
            cmd3.Parameters.AddWithValue("@InvoiceNo", "");
            cmd3.Parameters.AddWithValue("@InvoiceDate", "");
            cmd3.Parameters.AddWithValue("@Value", "");

            cmd3.ExecuteNonQuery();


            SqlConnection conn10, conn11;

            SqlCommand cmd10, cmd11, cmd12;

            ConnectionStringSettings setting1;
            setting1 = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"];
            string connstring2 = setting1.ConnectionString;

            conn10 = new SqlConnection(connstring2);
            conn10.Open();
            cmd10 = new SqlCommand("select Count(*) from POTable where PONO=@PONO", conn10);
            cmd10.Parameters.AddWithValue("@PONO", PONO);
            count = (int)cmd10.ExecuteScalar();
            pn = int.Parse(PONO);
            Flag = pn * 10;
            for (int j = 0; j &lt; count; j++)
            {
                cmd10 = new SqlCommand("select ProductCode from POTable where Flag=@Flag", conn10);
                cmd10.Parameters.AddWithValue("@Flag", Flag);
                ProductCode = (string)cmd10.ExecuteScalar();

                cmd10 = new SqlCommand("select ProductQty from POTable where Flag=@Flag", conn10);
                cmd10.Parameters.AddWithValue("@Flag", Flag);
                ProductQty = (string)cmd10.ExecuteScalar().ToString();

                cmd10 = new SqlCommand("select ProductBasePrice from POTable where Flag=@Flag", conn10);
                cmd10.Parameters.AddWithValue("@Flag", Flag);
                ProductBasePrice = (string)cmd10.ExecuteScalar().ToString();



                ConnectionStringSettings setting2;
                setting2 = System.Configuration.ConfigurationManager.ConnectionStrings["NewConnectionString"];
                string connstring3 = setting2.ConnectionString;
                conn11 = new SqlConnection(connstring3);
                conn11.Open();

                cmd11 = new SqlCommand("insert into OrbERP.dbo.CustProd values (@DocNum, @ItemCode , @ItemDescription, @Quantity , @Price , @TaxCode , @LineTotal , @Flag , @Catagory)", conn11);

                cmd11.Parameters.AddWithValue("@DocNum", PONO);
                cmd11.Parameters.AddWithValue("@ItemCode", ProductCode);
                cmd11.Parameters.AddWithValue("@ItemDescription", ProdDisp);
                cmd11.Parameters.AddWithValue("@Quantity", ProductQty);
                cmd11.Parameters.AddWithValue("@Price", ProductBasePrice);

                cmd11.ExecuteNonQuery();
                conn11.Close();
                Flag = Flag + 1;
            }
            conn10.Close();
        }
    }
   /* TextBox1.Text = usename;
     TextBox2.Text = i.ToString();

    string count = i.ToString();
    string Username = usename;

    string Loginname = Label2.Text; */
    Response.Redirect("SAPTrans.aspx");

}
</code></pre>

<p>this is my connection string code</p>

<pre><code>&lt;connectionStrings&gt;
    &lt;addname="ConnectionString"connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=C:\netnewworking\NEWWORKING\WebSite3\App_Data\ORBEnergy.mdf;Integrated Security=True;UserInstance=True" providerName="System.Data.SqlClient"/&gt;
</code></pre>

<p>


    </p>
