⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 converter.cs

📁 可以实现任意数据库之间的数据互导,可以实现任意数据库之间的数据互导
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using LC_XMLControl;
using System.IO;
using System.Collections;
using System.Data.Odbc;
using System.Windows.Forms;
using System.Data;

namespace CvsToXml
{
    public class Converter : IThransProtocol
    {

        #region IThransProtocol 成员
        private string filname,dir;
        private DataTable csvtable = new DataTable();
        public void closeDesConnection()
        {
            
        }

        public void closeSourceConnection()
        {
            
        }

        public void createDesContentction(string constr)
        {
            
        }

        public void createSourceContenction(string constr)
        {
            _sourceconnection = null;
            if (_sourceconnection != null) _sourceconnection.Close();
            dir = constr.Substring(0, constr.LastIndexOf("\\"));
            filname = constr.Substring( constr.LastIndexOf("\\")+1);
            filname = filname.Substring(0, filname.LastIndexOf("."));
            //MessageBox.Show(dir + "---" + filname);
            try
            {
                string str = "Driver={Microsoft Text Driver (*.txt; *.csv)};" + "Dbq=" + dir + ";Persist SecurityInfo=false;";
                _sourceconnection = new OdbcConnection(str);
                _sourceconnection.Open();
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message.ToString());
            }


        }
        private ArrayList _allres;
        public ArrayList allres
        {
            get
            {
                return _allres;
            }
            set
            {
                _allres = (ArrayList)value;
            }
        }
        private ArrayList _errorres;
        public ArrayList errorres
        {
            get
            {
                return _errorres;
            }
            set
            {
                _errorres = (ArrayList)value;
            }
        }
        private int _cursum;
        public int cursum
        {
            get
            {
                return _cursum;
            }
            set
            {
                _cursum = value;
            }
        }
        private object _desconnection;
        public object desconnection
        {
            get
            {
                return _desconnection;
            }
            set
            {
                _desconnection = value;
            }
        }
        private int _dtype;
        public int dtype
        {
            get
            {
                return _dtype;
            }
            set
            {
                _dtype = value;
            }
        }

        public System.Collections.ArrayList getAllDesField(string table)
        {
            return null;
        }

        public System.Collections.ArrayList getAllDesTable()
        {
            return null;
        }

        public System.Collections.ArrayList getAllSourceField(string table)
        {
            ArrayList temp = new ArrayList();
            OdbcCommand ocd = new OdbcCommand("select * from [" + table + ".csv]");
            ocd.Connection = _sourceconnection;
            OdbcDataAdapter oda = new OdbcDataAdapter(ocd);
            oda.Fill(this.csvtable);

            foreach (DataColumn column in csvtable.Columns)
            {
                temp.Add(column.ColumnName);
            }
            return temp;
        }

        public System.Collections.ArrayList getAllSourceTable()
        {
            ArrayList temp = new ArrayList();
            temp.Add(filname);
            return temp;
        }
        private string _info;
        public string info
        {
            get
            {
                return _info;
            }
            set
            {
                _info = value;
            }
        }

        private ArrayList _msg;
        public System.Collections.ArrayList msg
        {
            get
            {
                return _msg;
            }
            set
            {
                _msg = value;
            }
        }

        public System.Data.DataTable sourceToXml(string source, System.Collections.ArrayList allfield)
        {
            return csvtable;
        }
        private OdbcConnection  _sourceconnection;
        public object sourceconnection
        {
            get
            {
                return _sourceconnection;
            }
            set
            {
                _sourceconnection = (OdbcConnection)value;
            }
        }

        private string _spliter;
        public string spliter
        {
            get
            {
                return _spliter;
            }
            set
            {
                _spliter = value;
            }
        }
        private int _stype;
        public int stype
        {
            get
            {
                return _stype;
            }
            set
            {
                _stype = value;
            }
        }

        public void xmlToDes(string des, System.Collections.ArrayList rows, System.Collections.ArrayList field)
        {
            //return null;
        }

        #endregion
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -