日期:2014-05-17  浏览次数:20502 次

导Excel文件到Oracle,和导入到SQLSERVER里是否同样操作?
SQLSERVER是这么写的:
C# code

count = 0;//计数
string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strExcelFileName + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
            string strExcel = string.Format("select * from [{0}$]", strSheetName);//test
            StringBuilder sb = new StringBuilder();
            DataSet ds = new DataSet();
            using (OleDbConnection conn = new OleDbConnection(strConn))
            {
                conn.Open();
                OleDbDataAdapter adapter = new OleDbDataAdapter(strExcel, strConn);
                adapter.Fill(ds, strSheetName);
                conn.Close();
            }
            DataTable dt = ds.Tables[0];
            MCT_YYEQKB mCT_YYEQKB = new MCT_YYEQKB();
foreach (DataRow dr in dt.Rows)
            {
                //避免空数据干扰
                if (dr["妇女ID"].ToString() == "")
                {
                    break;
                }
                try
                {
                    mCT_YYEQKB.MCC_C0_01 = dr[0].ToString().Trim();
                    mCT_YYEQKB.MCC_C0_02 = dr[1].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_01 = dr[2].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_02 = dr[3].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_03 = dr[4].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_04 = dr[5].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_05 = dr[6].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_06 = dr[7].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_07 = dr[8].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_08 = dr[9].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_09 = dr[10].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_10 = dr[11].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_11 = dr[12].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_12 = dr[13].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_13 = dr[14].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_14 = dr[15].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_15 = dr[16].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_16 = dr[17].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_17 = dr[18].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_18 = dr[19].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_19 = dr[20].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_20 = dr[21].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_21 = dr[22].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_22 = dr[23].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_23 = dr[24].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_24 = dr[25].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_25 = dr[26].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_26 = dr[27].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_27 = dr[28].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_28 = dr[29].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_29 = dr[30].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_30 = dr[31].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_31 = dr[32].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_32 = dr[33].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_33 = dr[34].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_34 = dr[35].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_35 = dr[36].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_36 = dr[37].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_37 = dr[38].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_38 = dr[39].ToString().Trim();
                    mCT_YYEQKB.MCC_C2_39 = dr[40].ToStrin