我在一个网站上工作。在那两台服务器中,一台是本地服务器,另一台是主服务器..
我正在做移植,比如从本地服务器获取数据并移植到主服务器。主服务器是 SAP 服务器 .. 我必须将值从本地服务器移植到 SAP 服务器 .. 这样做时,如果网络出现故障或网络断开连接,我的移植速度会变慢.. 我也无法备份..
任何机构都可以帮我解决这个问题。如何克服这个问题。
这是我的网络配置文件..
这是我要移植的代码文件
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 < 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");
}
这是我的连接字符串代码
<connectionStrings>
<addname="ConnectionString"connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=C:\netnewworking\NEWWORKING\WebSite3\App_Data\ORBEnergy.mdf;Integrated Security=True;UserInstance=True" providerName="System.Data.SqlClient"/>