** 이녀석을 사정없이 벗겨본 이유 -_-?
엑셀 파일을 strProvider = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + FilePath + "; Extended Properties=\"Excel 8.0; HDR=No;\""; 를 통해 읽어들이는대..
Sheet Name를 가져오기 위해서.
DataTable dt = oleDBCon.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
조런 코드를 작성해놓았다.
그리고 DataTable를 읽어보는데!!!
헉쑤!! DataTable이 null?!!!
이 녀석이 null 을 반환하는 이유를 알고 싶었다 -_-ㅋ
(그리고.. 그냥 까보고 싶었어 ㅠ_ㅠ)
public DataTable GetOleDbSchemaTable(Guid schema, object[] restrictions) { DataTable table; IntPtr ptr; ExecutePermission.Demand(); Bid.ScopeEnter(out ptr, "<oledb.OleDbConnection.GetOleDbSchemaTable|API> %d#, schema=%p{GUID}, restrictions\n", this.ObjectID, schema); try { this.CheckStateOpen("GetOleDbSchemaTable"); OleDbConnectionInternal openConnection = this.GetOpenConnection(); if (OleDbSchemaGuid.DbInfoLiterals == schema) { if ((restrictions != null) && (restrictions.Length != 0)) { throw ODB.InvalidRestrictionsDbInfoLiteral("restrictions"); } return openConnection.BuildInfoLiterals(); } if (OleDbSchemaGuid.SchemaGuids == schema) { if ((restrictions != null) && (restrictions.Length != 0)) { throw ODB.InvalidRestrictionsSchemaGuids("restrictions"); } return openConnection.BuildSchemaGuids(); } if (OleDbSchemaGuid.DbInfoKeywords == schema) { if ((restrictions != null) && (restrictions.Length != 0)) { throw ODB.InvalidRestrictionsDbInfoKeywords("restrictions"); } return openConnection.BuildInfoKeywords(); } if (openConnection.SupportSchemaRowset(schema)) { return openConnection.GetSchemaRowset(schema, restrictions); } using (IDBSchemaRowsetWrapper wrapper = openConnection.IDBSchemaRowset()) { if (wrapper.Value == null) { throw ODB.SchemaRowsetsNotSupported(this.Provider); } } throw ODB.NotSupportedSchemaTable(schema, this); } finally { Bid.ScopeLeave(ref ptr); } return table; }
뭐 보면 알겠지만 -_-ㅋ 이건 뭥미 =ㅅ=!!!!
OleDbSchemaGuid 를 비교하는 것까지는 대충 이해했지만..
그 다음에 나온 녀석들은 -_- 뭐.. 성전 MSDN에도 안나오고..
쳇...
뭐 여튼.. 결론만 말해보자면..
Provider 에서 선언한 File에 대한 접근이 정상적이지 않을때.
파일이 없거나 할때. 상큼하게 null 을 뱉어주심.
창피한 이야기지만...
애당초 알고 있었다.
단지.. 파일 경로명을 잘못 적어놓고, 실제로 저장된 파일을 열어보면 파일은 아~무 문제도 없고..
그저 파일도 정상인데. 커넥션도 열리는데. 왜 왜!! null인것이냐!! 라고 울부짖은것 뿐..
커넥션이야 뭐.. 파일이 있건 없건 잘 열리겠지만....
정말 결론은.. 그저.. 뻘짓 + 삽질 + 창피
쳇쳇쳇..
'Error 이야기' 카테고리의 다른 글
oracle 자원이 사용중이고 NOWAIT가 지정되어 있다. (0) | 2011.02.15 |
---|---|
C# Excel 시트 보호 해제 시 발생했던 에러. (0) | 2010.10.18 |
C# Excel Range 선언시 시트 보호 에러 (0) | 2010.10.15 |
엑셀 Application 을 통해서 파일 접근 시 COM 클래스 팩터리를 검색하지 못했습니다. 에러. (0) | 2010.10.14 |
OleDb를 통한 Excel File Reading 시 발생할 수 있는 문제. (0) | 2010.10.14 |