0

我正在将网站转换为新网站CMS,但德国网站数据库都是MySQL databases,但CMS可以通过SQLServer。因此我不得不进行数据库转换,我已经完成了一个伪代码,并且还使用 Microsoft Visual Studio 在 C# 中启动了该程序,但是由于我只使用c# in asp.net了 cms 格式,这是我第一次真正的 C# 编程尝试,所以请原谅我的代码中可能已经存在的一些可怕错误,即使没有我错过的部分。

nb 我知道数据库对于某些表方面有不同的名称,例如数据和时间,但数据库中没有会导致冲突的名称。

伪:

                         /*start loop 
                         *connect to MYSQL
                         * is there a table to use? if yes begin loop, else Exit, & disconnect from MYSQL;
                         * begin iteration on Table N
                         * Read table list 
                            SELECT COUNT(*)
                            FROM INFORMATION_SCHEMA.COLUMNS
                            where Table_name ='Current selected table' 
                         *  execute
                         * Disconnect from MYSQL 
                         * 
                         * Connect to MS SQL
                         * create new table in MS SQL USing read data
                         * Create Table [same name as other table, with columns from      other place]
                         * (all column names in here,sfg, bgfgb,dgb)
                         * ececute command, creating a new table
                         * Disconnect from MSSQL
                         * 
                         * Connect to MySQl
                         *  return all data within table n,
                         *  
                         * Select * From [table name];
                         * Disconnect MySQL
                         *  
                         * Connect MS SQL 
                         * INSERT INTO (table name)
                         * VALUES ( columsn 1, 2, 3, 4 etc)
                         * 
                         * execute
                         * Disconnect MS SQL, 
                         * 
                         * Table N +1 //next itteration
                         *  
                         * insert into new table Values (data from mySQL)
                         * once all have been complete loop until ended
                         * program will leave when no tables left
                         */

到目前为止,这是我在 C# 中创建的:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using MySql.Data.MySqlClient;
using System.Configuration;


namespace dbconverter
{
    public class program
    {
        public static void Main(string[] args)
        {
            MySqlDataAdapter _Myadp = new MySqlDataAdapter();
            int i = 0; i < _Table.Count; i++;
        }
        public static void ConnectMySQL()
        {
            string cs = @"MYSQLconnectionstring";

            MySqlConnection conn = null;

            try
            {
                conn = new MySqlConnection(cs);
                conn.Open();

                if (conn == null)
                {
                    Console.WriteLine("connection could not be established");
                }
                else
                {
                    Console.WriteLine("connection was successful");
                }
            }
        }

        public static void SearchTables()
        {
            MySqlDataAdapter _Myadp = new MySqlDataAdapter();

            _Myadp.SelectCommand.CommandText = "show tables;";
        }
        public static void ChooseTable()
        {

            //Show all tables,
            //have loop internal of main()

        }
        public static void CopyTable()
        {
            MySqlDataAdapter _Myadp = new MySqlDataAdapter();

            _Myadp.Fill(_Table);

        }
        public static void connectMsSQL()
        {
            SqlConnection _con = new SqlConnection(ConfigurationManager.ConnectionStrings["MSconnectionstring"].ConnectionString);

            _con.Open();

        }
        public static void CreateTable()
        {

            if (_Table != null)
            {
                if (_Table.Rows.Count > 0)
                {
                    _return= new List<>();

                    for (int a = 0; a< _Table.Count; a++)
                    {
                        _return.Add(new_Table());
                        _Return[a].List<> = Convert.ToString(_table[int][" *-(ALL) "]);
                    }
                }
            }
        }

        public static void CopyMySQLTableData()
        {
            MySqlDataAdapter _Myadp = new MySqlDataAdapter();
            _Myadp.SelectCommand.CommandText = "SELECT (*) FROM [_Table];";
            //return to table
        }
        public static void InsertDataMsSQL()
        {
            if (_Table != null)
            {
                if (_Table.Rows.Count > 0)
                {
                    _return= new List<>();

                    for (int a = 0; a< _Table.Count; a++)
                    {
                        _return.Add(new_Table());
                        _Return[a].List<> = Convert.ToString(_table[int][" *-(ALL) "]);
                    }
                }
            }
        }

    }
}

如果有人有时间,我基本上需要一些关于我现在如何处理我创建的类的建议,[ Main() class ] 以便将它们全部组合成一个遵循伪结构的工作程序。

提前谢谢了

4

0 回答 0