这是我连EXCEL数据库的一段代码,我想把EXCEL中的数据读出来导到SQL数据库中,由于中间还存在其他操作,所以我先把数据存入一个数组:但是运行的时候出现这个提示:HRESULT中的异常:0x800A03EC
MSDN上说是因为OFFICE的语言版本和系统区域设置不同,但是我换过来了还是不行,即使在本机上可以了,那我的程序跑在其他人的机子上不是也只能在特定的语言环境下运行?
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
  try
   {
     int row=new int();
     int col=new int();
     int indexTemp=this.listBox1.SelectedIndex;
     Excel.Worksheet xSheet=(Excel.Worksheet)xBook.Sheets[indexTemp+1];

     row=xSheet.Rows.Count;
     col=xSheet.Columns.Count;
     string[,] temp = new string[row,col];     for(int i=1;i<row;i++)
     {
for(int j=0;j<col;j++)
{
  temp[i,j]=xSheet.get_Range(i,j).ToString();
}
     }
     for(int i=0;i<1;i++)
    {
for(int j=0;j<col;j++)
{
this.checkedListBox1.Items.Add(col.ToString());    
}
    }

  }catch(Exception err)
  {
MessageBox.Show(err.Message);
  }
}另外还有一段代码,是连SQL数据库的。执行到 SqlCommand thisCommand=thisConnection.CreateCommand();处
提示:未处理的“system.data.sqlclient.sqlexception”类型的异常出现在system.data.dll中。其他信息:系统错误
private void  MySaveFile()
{
this.listBox3.Items.Clear();
SqlConnection thisConnection= new SqlConnection(@"Integrated Security=SSPI;Initial Catalog="+saveFilePath+";Data Source=(local);");
thisConnection.Open();
SqlCommand thisCommand=thisConnection.CreateCommand();
thisCommand.CommandText="select name from sysobjects where xtype=u";
SqlDataReader thisReader=thisCommand.ExecuteReader();
foreach(String item in thisReader)  
{
this.listBox1.Items.Add(item.ToString());
}

}
如果我只想往数据库里INSERT数据,可否不打开数据库而直接执行?在线等啊,救命~~~