달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

** 이녀석을 사정없이 벗겨본 이유 -_-?
 엑셀 파일을 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인것이냐!! 라고 울부짖은것 뿐..
 
커넥션이야 뭐.. 파일이 있건 없건 잘 열리겠지만....
 
정말 결론은.. 그저.. 뻘짓 + 삽질 + 창피 
 
쳇쳇쳇..
 
Posted by 은하비류연
|