private void btnSave_Click(object sender, EventArgs e) { string str = string.Empty; DataSet ds1 = new DataSet(); DataView dv; string clientdata=""; foreach (var clientItem in checkedListBoxClientTableField.CheckedItems) { if (checkedListBoxClientTableField.SelectedIndex > -1) { foreach(DataRowView dataFromClient in checkedListBoxClientTableField.CheckedItems) { clientdata=dataFromClient[0].ToString(); } MySqlConnection myconn3; string SelectClientData = "Data Source="+lblSaveSeverIpClient.Text +";Initial Catalog=" + lblSqlDatabaseClient.Text + ";user id="+lblSaveUserNameClient.Text +";password="+ lblSavePasswordClient.Text +""; myconn3 = new MySqlConnection(SelectClientData); myconn3.Open(); str = clientdata.ToString(); string query = "Select " + str + " from " + lblSqlDatabaseClient.Text + "." + lblMySqlTableNameClient.Text + ""; MySqlDataAdapter mydata = new MySqlDataAdapter(query, myconn3); DataTable dTable = new DataTable(); mydata.Fill(ds1, str); dv = ds1.Tables[0].DefaultView; DataTable table = ds1.Tables[0]; dv.Sort = "" + str + " DESC"; myconn3.Close(); } // int a = 0; foreach (DataTable dt in ds1.Tables) { } if (ds1.Tables.Count > 0) { string strForSqlServer = string.Empty; DataSet dsForSqlServer = new DataSet(); string strInt=""; foreach (var listOFSQLIntelect in checkedListBoxIntTable.CheckedItems) { if (checkedListBoxIntTable.SelectedIndex > -1) { foreach(DataRowView DriInternal in checkedListBoxIntTable.CheckedItems) { strInt=DriInternal[0].ToString(); } SqlConnection sqlconForMigration; string SqlServerInsert = "Data Source=" + lblSaveSeverIpIntellect.Text + ";Initial Catalog=" + lblSqlDatabase.Text + ";user id=" + lblSaveUserNameIntellect.Text + ";password=" + lblSavePasswordIntellect.Text + ""; // string SqlServerInsert = "Data Source=localhost;Initial Catalog=" + lblSqlDatabase.Text + ";user id=root;password=root"; foreach (DataRow dr in ds1.Tables[0].Rows) { sqlconForMigration = new SqlConnection(SqlServerInsert); sqlconForMigration.Open(); strForSqlServer = strInt.ToString(); string query = "insert into " + lblSqlTableName.Text + "(" + strForSqlServer + ") values ('" + dr[0].ToString() + "')"; SqlCommand cmd = new SqlCommand(query, sqlconForMigration); cmd.ExecuteNonQuery(); sqlconForMigration.Close(); } } } string message = "Record Added In MSSQL Table"; string title = "Title"; MessageBox.Show(message); } } //string path = "D:\\Expences.xml"; //XmlDocument doc = new XmlDocument(); ////If there is no current file, then create a new one //if (!System.IO.File.Exists(path)) //{ // //Create neccessary nodes // XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", "yes"); // XmlComment comment = doc.CreateComment("This is an XML Generated File"); // doc.AppendChild(declaration); // doc.AppendChild(comment); //} //else //If there is already a file //{ // doc.Load(path); //} }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)