QQ IP library IP format conversion

zhaozj2021-02-16  88

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

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 = communication.toint64 (iptemp2 [0]) * 256 * 256 * 256 convert.Toint64 (iptemp2 [1]) * 256 * 256 Convert.Toint 64 (iptemp2 [2]) * 256 Convert.Toint64 (iptemp2 [3]); string addrf = DR [3] .tostring (). Replace ("'", " '' "); Cmd2.commandtext =" INSERT 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");

转载请注明原文地址:https://www.9cbs.com/read-12521.html

New Post(0)