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

还是关于sql批量导入的问题,求指教!
现在报了个这样的错!!

然后这段我是这样写的

   private void bind(string fileName)
        {
          //  int i = 0;
            string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties='Excel 12.0;HDR=YES;IMEX=2;'";

            OleDbConnection con1 = new OleDbConnection(strConn);
            con1.Open();
            DataTable sheetNames = con1.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });


        //    string sheetname = sheetable.Rows[i]["Table_Name"].ToString();//在这一行有时报错
            //  MessageBox.Show(sheetname);
           //   String a1 = "学生基本信息表";
                OleDbDataAdapter da = new OleDbDataAdapter("SELECT * From [Sheet1$] ", strConn);
          //    OleDbDataAdapter da = new OleDbDataAdapter("SELECT * From [Sheet1$] ", strConn);

                string[] a = new string[100];
                SqlConnection coon = new SqlConnection();
                coon.ConnectionString = "data source = .;initial catalog = School; user id = sa;password = 4380364054";
                try
                {
                    coon.Open();
                    Console.WriteLine("数据库连接成功");
                    button2.Enabled = false;
                    InData.Enabled = true;
                    MessageBox.Show("数据库连接成功");
                }
                catch (Exception ex)
                {
   &nbs