Example #1
0
        public int Excel_InsertProductList(DataTable dtData, int index, int Total)
        {
            int    Result        = 0;
            string strSql        = string.Empty;
            string strSql_Midden = string.Empty;
            string strSql_End    = string.Empty;

            strSql = "Insert into product_list (";
            for (int i = 0; i < dtData.Columns.Count; i++)
            {
                string Value = dtData.Rows[0][dtData.Columns[i].ColumnName].ToString();
                if (Value == string.Empty)
                {
                    continue;
                }
                if (strSql_Midden == string.Empty)
                {
                    strSql_Midden = dtData.Columns[i].ColumnName;
                }
                else
                {
                    strSql_Midden = strSql_Midden + "," + dtData.Columns[i].ColumnName;
                }

                if (strSql_End == string.Empty)
                {
                    strSql_End = Value;
                }
                else
                {
                    strSql_End = strSql_End + "," + Value;
                }
            }

            strSql = strSql + strSql_Midden + ") VALUES(" + strSql_End + ")";
            Result = dbhelpersqlformess.BatchOperateDATA(strSql, index, Total);
            return(Result);
        }