MySqlConnection con = new MySqlConnection("SERVER=192.168.3.1;DATABASE=mysar;UID=root;PASSWORD=xxxx;"); SqlConnection sqlcon = new SqlConnection("Data Source=RMS;Initial Catalog=TestMySQLLinuxProxyServer;Integrated Security=True"); sqlcon.Open(); try { con.Open(); MessageBox.Show("Connection is established"); MySqlCommand cmd = new MySqlCommand("select * from mysar.traffic", con); MySqlDataReader datareader = cmd.ExecuteReader(); string[] s = new string[10]; int i = 0; string tempstring; while (datareader.Read()) { //list[0].Add(dataReader["id"] + ""); ////id,ip,description,isResolved,hostname //hostnames[0].Add(datareader["id"] + ""); //hostnames[1].Add(datareader["ip"]+ ""); //hostnames[2].Add(datareader["description"] + ""); //hostnames[3].Add(datareader["isResloved"] + ""); //hostnames[4].Add(datareader["hostname"] + ""); //MessageBox.Show(hostnames[0].ToString()); int j = 0; for (i = 0; i < datareader.FieldCount; i++) { //MessageBox.Show(datareader[i].ToString()); tempstring = datareader[i].ToString(); s[j] = tempstring; j++; if ((i % 9) == 0 && i != 0) { //MessageBox.Show(s[0]+s[1]+s[2]+s[3]+s[4]); SqlCommand sqlcmd = new SqlCommand("insert into traffic values('" + @s[0] + "','" + @s[1] + "','" + @s[2] + "','" + @s[3] + "','" + @s[4] + "','" + @s[5] + "','" + @s[6] + "','" + @s[7] + "','" + @s[8] + "','" + @s[9] + "')", sqlcon); sqlcmd.ExecuteNonQuery(); j = 0; } //MessageBox.Show(s[i].ToString()); } } MessageBox.Show(datareader.FieldCount.ToString()); sqlcon.Close(); datareader.Close(); con.Close(); MessageBox.Show(s[0]); //List< string >[] list = new List< string >[3]; } catch (Exception ex12) { MessageBox.Show(ex12.ToString()); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)