搞定了,原来是转义符的问题,
在C#下利用ADO.NET把Excel表直接导入到SQL Server 2000的代码如下:
SqlConnection sqlConnection1 = new SqlConnection("server=(local);integrated security=SSPI;initial catalog=Library");
//SqlConnection sqlConnection1 = new SqlConnection();
//sqlConnection1.ConnectionString = "server=(local);integrated security=SSPI;initial catalog=Library";
string importSQL = "SELECT * into live41 FROM OpenDataSource" +
"('Microsoft.Jet.OLEDB.4.0','Data Source=" + "\"" + "E:\\022n.xls" + "\"" +
"; User ID=;Password=; Extended properties=Excel 5.0')...[Sheet1$]";
//把E:\022n.xls的Sheet1$表 创建到Library数据库的live41表中
try
{
sqlConnection1.Open();
SqlCommand sqlCommand1 = new SqlCommand();
sqlCommand1.Connection = sqlConnection1;
sqlCommand1.CommandText = importSQL;
sqlCommand1.ExecuteNonQuery();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}