我的目的是通过FileUpload控件或者其他的类似的控件能选择一个execl文件,然后读取此文件,通过datatable临时存储,最后存储到access数据库中
我是新人,高手们帮帮忙吧~
回答的时候最好附上代码,越详细越好
谢谢啦~我会在线等的~

解决方案 »

  1.   

    使用DataSet读Excel
    代码见参考
    参考1
    参考2
      

  2.   

    把Excel数据读入到Dataset 
     string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";   
                strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\couse.xlsx;";   
                strConnection += "Extended Properties=\"Excel 12.0 Xml;HDR=YES\";";   
                OleDbConnection objConnection = new OleDbConnection(strConnection);   
                objConnection.Open();   
                OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from [Sheet1$]", objConnection);   
                DataSet ds = new DataSet();   
                myCommandd.Fill(ds, "[Sheet1$]");   
                System.Data.DataTable dt = ds.Tables["[Sheet1$]"];   
                Console.WriteLine(dt.Columns[0].ToString());   
                Console.WriteLine(dt.Columns[1].ToString());   本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154784.aspx
      

  3.   

    Datase回冲到Access #region Access 2007   
                Console.WriteLine("Access 2007");   
                string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";   
                strConnection += @"Data Source=C:\Documents and Settings\v-changl\My Documents\Database1.accdb;";   
                strConnection += "Persist Security Info=False";   
                using (OleDbConnection objConnection = new OleDbConnection(strConnection))   
                {   
                    objConnection.Open();   
                    OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from Couse", objConnection);   
                    DataSet ds = new DataSet();   
                    myCommandd.Fill(ds, "couse");   
                    DataTable dt = ds.Tables["couse"];   
                    Console.WriteLine(dt.Columns[0].ToString());   
                    Console.WriteLine(dt.Columns[1].ToString());   
                    Console.WriteLine(dt.Columns[2].ToString());   
      
                    objConnection.Close();   
      
                }  
                #endregion   
    本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/LCL_data/archive/2009/05/06/4154255.aspx
      

  4.   

    楼上的好像是用控制台程序啊,能不能直接用web做个例子啊~
    人比较笨,谢谢啦~