Excel 2010 쿼리 시 OLEDB 예외 진단
-
13-09-2019 - |
문제
SQL을 통해 Excel 시트를 쿼리하려면 다음 중 하나를 사용했습니다.
Dim excelConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strPath + ";Extended Properties=""Excel 8.0;IMEX=1;HDR=YES;"""
또는
Dim excelConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + strPath + ";Extended Properties=""Excel 12.0;IMEX=1;HDR=YES;"""
이제 Office 2010을 설치하기 전까지는 정상적으로 작동했습니다.
이제 나는
Microsoft.ace.oledb.12.0 제공 업체는이 컴퓨터 예외에 등록되지 않았습니다.
올바른 연결 문자열/공급자를 어떻게 찾을 수 있나요?
해결책
아마도 ACE(Access Database Engine) 구성 요소를 제거했습니까?MSDN에서 계속 다운로드할 수 있습니다. 2007 오피스 시스템 드라이버:데이터 연결 구성 요소.
다른 팁
나는 Excel 2010을 믿습니다.
Dim excelConnectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Password="""";User ID=Admin;Data Source=D:\\MyDocs\\oledb.xlsx;Mode=Share Deny Write;Extended Properties=""HDR=YES;"";Jet OLEDB:Engine Type=37"
이것은 내 Visual Studio에서 작동하는 것으로 보이며 쿼리 문자열을 생성하기 위해 Excel을 얻었고 추가 항목이 있습니다.
사무실 시스템 드라이버 : 데이터 연결 구성 요소를 다운로드하여 설치했으며 아래 코드는 다음과 같습니다.
string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Password=\"\";User ID=Admin;Data Source=d:\\Sample.xlsx;Mode=Share Deny Write;Extended Properties=\"HDR=YES;\";Jet OLEDB:Engine Type=37";
OleDbConnection connection = new OleDbConnection(connectionString);
try
{
connection.Open();
OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet1$]", connection);
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter.SelectCommand = command;
DataSet ds = new DataSet();
adapter.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
catch (Exception)
{
//throw;
}
finally
{
connection.Close();
}
제휴하지 않습니다 StackOverflow