Пример #1
0
        private void tsb_upload_Click(object sender, EventArgs e)
        {
            List <string> DB_info = new List <string>();

            DB_info.Add(tb_ServerName.Text);
            DB_info.Add(tb_DBName.Text);
            DB_info.Add(tb_UserName.Text);
            DB_info.Add(tb_Pw.Text);
            DB_info.Add(tb_TableName.Text);

            if (DB_info.Contains(""))
            {
                MessageBox.Show("please check DB info");
            }
            else
            {
                List <string> TableName = Get_TABLEName(DB_info);
                if (TableName.Count != 0 && dgv_data.Columns.Count == TableName.Count)
                {
                    string   strmsg = "";
                    sqlClass sql    = new sqlClass();
                    sql.Sql_conn(DB_info, out strmsg);
                    foreach (DataRow dr in dt_ExcelData.Rows)
                    {
                        sql.UPDATE_Excel_To_SQL_Table(dr, DB_info, TableName, out strmsg);
                        tsl_msg.Text = strmsg;
                    }
                    sql.Sql_Close();
                }
            }
        }
Пример #2
0
        private List <string> Get_TABLEName(List <string> DB_info)
        {
            string   strmsg = "";
            sqlClass sql    = new sqlClass();

            sql.Sql_conn(DB_info, out strmsg);
            DataTable     dt         = sql.SELECT_TABLE(DB_info, out strmsg);
            List <string> columnName = new List <string>();

            foreach (DataColumn name in dt.Columns)
            {
                columnName.Add(name.ColumnName.ToString());
            }
            sql.Sql_Close();
            return(columnName);
        }