Пример #1
0
        private void convert(String tableName)
        {
            //get row count
            ///-------------------------------------------------------

            using (var sqlCon = new SqlConnection(Connection.PropConnString)) {
                sqlCon.Open();

                var com = sqlCon.CreateCommand();
                com.CommandText = "select * from " + tableName;
                using (var reader = com.ExecuteReader()) {
                    //here you retrieve what you need
                }

                com.CommandText = "select @@ROWCOUNT";
                int totalRowa = Convert.ToInt32(com.ExecuteScalar());
                totalrow.setv(totalRowa);
                sqlCon.Close();
            }
            // MessageBox.Show(">> " + totalRow);
            ///-----------------------------------------------------------------------
            //write(tableName,
            //    "SET SQL_MODE = \"NO_AUTO_VALUE_ON_ZERO\";" +
            //    "\nSET time_zone = \"+00:00\";");
            write(tableName, string.Format("\nCREATE TABLE IF NOT EXISTS `{0}` (", tableName));
            //this will creating the table
            List <string> columnsANDTypes = ColumnNamesANDTypes.getColumnNameANDType(tableName);
            int           size            = columnsANDTypes.Count;
            int           inc             = 0;

            foreach (string column in columnsANDTypes)
            {
                inc++;
                write(tableName, "\t" + column + ((inc < size) ? "," : ""));
            }
            FileManagerTask.writeFile(fileLocation_txt.Text, tableName, ");");


            //this will inerting data into a created table
            List <string> names = ColumnNames.getColumnName(tableName);

            write(tableName, string.Format("INSERT INTO `{0}` (", tableName));;
            inc = 0;
            foreach (string name in names)
            {
                inc++;
                write(tableName, "\t`" + name + "`" + ((inc < size) ? "," : ""));
            }
            write(tableName, ") VALUES");
            int row = AllData.getAllDAta(backgroundWorker, fileLocation_txt.Text, names, tableName, tableName, ColumnTypes.getColumnTypes(tableName));
        }
Пример #2
0
 private static void write(string dir, string fi, string towrite)
 {
     FileManagerTask.writeFile(dir, fi, towrite);
 }
Пример #3
0
 private void write(string fileName, string towrite)
 {
     FileManagerTask.writeFile(fileLocation_txt.Text, fileName, towrite);
 }