SqlConnection conn=new SqlConnection();
SqlConnection conn2=new SqlConnection();
SqlCommand cmd=new SqlCommand();
SqlCommand cmd2=new SqlCommand();
conn.ConnectionString="workstation id=4KASTOR;packet size=4096;integrated security=SSPI;data source=4KASTOR;persist security info=False;initial catalog=ip";
conn2.ConnectionString="workstation id=4KASTOR;packet size=4096;integrated security=SSPI;data source=4KASTOR;persist security info=False;initial catalog=ip";
conn.Open();
conn2.Open();
cmd.Connection=conn;
cmd2.Connection=conn2;
cmd.CommandText="select * from ip13";
SqlDataReader dr=cmd.ExecuteReader();
while(dr.Read())
{
string [] ipTemp=dr[0].ToString().Split('.');
string [] ipTemp2=dr[1].ToString().Split('.');
long ipFrom=Convert.ToInt64(ipTemp[0])*256*256*256+Convert.ToInt64(ipTemp[1])*256*256+Convert.ToInt64(ipTemp[2])*256+Convert.ToInt64(ipTemp[3]);
long ipTo=Convert.ToInt64(ipTemp2[0])*256*256*256+Convert.ToInt64(ipTemp2[1])*256*256+Convert.ToInt64(ipTemp2[2])*256+Convert.ToInt64(ipTemp2[3]);
string addrf=dr[3].ToString().Replace("'","''");
cmd2.CommandText="INSERT INTO IP13N (onip,offip,addj,addf) VALUES('"+ipFrom.ToString()+"','"+ipTo.ToString()+"','"+dr[2].ToString()+"','"+addrf +"')";
cmd2.ExecuteNonQuery();
}
dr.Close();
cmd.Dispose();
cmd2.Dispose();
conn.Close();
conn.Dispose();
MessageBox.Show("ok");