xref: /trunk/main/connectivity/source/drivers/ado/adoimp.cxx (revision cf6516809c57e1bb0a940545cca99cdad54d4ce2)
19b5730f6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
39b5730f6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
49b5730f6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
59b5730f6SAndrew Rist  * distributed with this work for additional information
69b5730f6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
79b5730f6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
89b5730f6SAndrew Rist  * "License"); you may not use this file except in compliance
99b5730f6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
119b5730f6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
139b5730f6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
149b5730f6SAndrew Rist  * software distributed under the License is distributed on an
159b5730f6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
169b5730f6SAndrew Rist  * KIND, either express or implied.  See the License for the
179b5730f6SAndrew Rist  * specific language governing permissions and limitations
189b5730f6SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
209b5730f6SAndrew Rist  *************************************************************/
219b5730f6SAndrew Rist 
229b5730f6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_connectivity.hxx"
26cdf0e10cSrcweir #include <com/sun/star/sdbcx/Privilege.hpp>
27cdf0e10cSrcweir #include <com/sun/star/sdbcx/PrivilegeObject.hpp>
28cdf0e10cSrcweir #include "connectivity/dbexception.hxx"
29cdf0e10cSrcweir #include "ado/Awrapado.hxx"
30cdf0e10cSrcweir #include "ado/adoimp.hxx"
31cdf0e10cSrcweir #include <osl/diagnose.h>
32cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
33cdf0e10cSrcweir 
34cdf0e10cSrcweir 
35cdf0e10cSrcweir using namespace connectivity::ado;
36cdf0e10cSrcweir using namespace com::sun::star::uno;
37cdf0e10cSrcweir using namespace com::sun::star::sdbc;
38cdf0e10cSrcweir using namespace com::sun::star::sdbcx;
39cdf0e10cSrcweir 
40cdf0e10cSrcweir 
41cdf0e10cSrcweir #define MYADOID(l) {l, 0,0x10,0x80,0,0,0xAA,0,0x6D,0x2E,0xA4};
42cdf0e10cSrcweir 
43cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCONNECTION_21    =   MYADOID(0x00000514);
44cdf0e10cSrcweir const IID   ADOS::IID_ADOCONNECTION_21      =   MYADOID(0x00000550);
45cdf0e10cSrcweir 
46cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCOMMAND_21       =   MYADOID(0x00000507);
47cdf0e10cSrcweir const IID   ADOS::IID_ADOCOMMAND_21         =   MYADOID(0x0000054E);
48cdf0e10cSrcweir 
49cdf0e10cSrcweir const CLSID ADOS::CLSID_ADORECORDSET_21     =   MYADOID(0x00000535);
50cdf0e10cSrcweir const IID   ADOS::IID_ADORECORDSET_21       =   MYADOID(0x0000054F);
51cdf0e10cSrcweir 
52cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCATALOG_25       =   MYADOID(0x00000602);
53cdf0e10cSrcweir const IID ADOS::IID_ADOCATALOG_25           =   MYADOID(0x00000603);
54cdf0e10cSrcweir 
55cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOINDEX_25         =   MYADOID(0x0000061E);
56cdf0e10cSrcweir const IID ADOS::IID_ADOINDEX_25             =   MYADOID(0x0000061F);
57cdf0e10cSrcweir 
58cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOTABLE_25         =   MYADOID(0x00000609);
59cdf0e10cSrcweir const IID ADOS::IID_ADOTABLE_25             =   MYADOID(0x00000610);
60cdf0e10cSrcweir 
61cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOKEY_25           =   MYADOID(0x00000621);
62cdf0e10cSrcweir const IID ADOS::IID_ADOKEY_25               =   MYADOID(0x00000622);
63cdf0e10cSrcweir 
64cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOCOLUMN_25        =   MYADOID(0x0000061B);
65cdf0e10cSrcweir const IID ADOS::IID_ADOCOLUMN_25            =   MYADOID(0x0000061C);
66cdf0e10cSrcweir 
67cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOGROUP_25         =   MYADOID(0x00000615);
68cdf0e10cSrcweir const IID ADOS::IID_ADOGROUP_25             =   MYADOID(0x00000616);
69cdf0e10cSrcweir 
70cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOUSER_25          =   MYADOID(0x00000618);
71cdf0e10cSrcweir const IID ADOS::IID_ADOUSER_25              =   MYADOID(0x00000619);
72cdf0e10cSrcweir 
73cdf0e10cSrcweir const CLSID ADOS::CLSID_ADOVIEW_25          =   MYADOID(0x00000612);
74cdf0e10cSrcweir const IID ADOS::IID_ADOVIEW_25              =   MYADOID(0x00000613);
75cdf0e10cSrcweir 
GetKeyStr()76cdf0e10cSrcweir OLEString& ADOS::GetKeyStr()
77cdf0e10cSrcweir {
78cdf0e10cSrcweir     static OLEString sKeyStr(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gxwaezucfyqpwjgqbcmtsncuhwsnyhiohwxz")));
79cdf0e10cSrcweir     return sKeyStr;
80cdf0e10cSrcweir }
81cdf0e10cSrcweir 
82cdf0e10cSrcweir // -------------------------------------------------------------------------
MapADOType2Jdbc(DataTypeEnum eType)83cdf0e10cSrcweir sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType)
84cdf0e10cSrcweir {
85*be099857Smseidel     sal_Int32 nType = DataType::VARCHAR;
86cdf0e10cSrcweir     switch (eType)
87cdf0e10cSrcweir     {
88cdf0e10cSrcweir         case adUnsignedSmallInt:
89cdf0e10cSrcweir         case adSmallInt:            nType = DataType::SMALLINT;     break;
90cdf0e10cSrcweir         case adUnsignedInt:
91cdf0e10cSrcweir         case adInteger:             nType = DataType::INTEGER;      break;
92cdf0e10cSrcweir         case adUnsignedBigInt:
93cdf0e10cSrcweir         case adBigInt:              nType = DataType::BIGINT;       break;
94cdf0e10cSrcweir         case adSingle:              nType = DataType::FLOAT;        break;
95cdf0e10cSrcweir         case adDouble:              nType = DataType::DOUBLE;       break;
96cdf0e10cSrcweir         case adCurrency:            nType = DataType::DOUBLE;       break;
97cdf0e10cSrcweir         case adVarNumeric:
98cdf0e10cSrcweir         case adNumeric:             nType = DataType::NUMERIC;      break;
99cdf0e10cSrcweir         case adDecimal:             nType = DataType::DECIMAL;      break;
100cdf0e10cSrcweir         case adDBDate:              nType = DataType::DATE;         break;
101cdf0e10cSrcweir         case adDBTime:              nType = DataType::TIME;         break;
102cdf0e10cSrcweir         case adDate:
103cdf0e10cSrcweir         case adDBTimeStamp:         nType = DataType::TIMESTAMP;    break;
104cdf0e10cSrcweir         case adBoolean:             nType = DataType::BOOLEAN;      break;
105cdf0e10cSrcweir //      case adArray:               nType = DataType::ARRAY;        break;
106cdf0e10cSrcweir         case adBinary:              nType = DataType::BINARY;       break;
107cdf0e10cSrcweir         case adGUID:                nType = DataType::OBJECT;       break;
108cdf0e10cSrcweir         case adBSTR:
109cdf0e10cSrcweir         case adVarWChar:
110cdf0e10cSrcweir         case adWChar:
111cdf0e10cSrcweir         case adVarChar:             nType = DataType::VARCHAR;      break;
112cdf0e10cSrcweir         case adLongVarWChar:
113cdf0e10cSrcweir         case adLongVarChar:         nType = DataType::LONGVARCHAR;  break;
114cdf0e10cSrcweir         case adVarBinary:           nType = DataType::VARBINARY;    break;
115cdf0e10cSrcweir         case adLongVarBinary:       nType = DataType::LONGVARBINARY;break;
116cdf0e10cSrcweir         case adChar:                nType = DataType::CHAR;         break;
117cdf0e10cSrcweir         case adUnsignedTinyInt:
118cdf0e10cSrcweir         case adTinyInt:             nType = DataType::TINYINT;      break;
119cdf0e10cSrcweir         case adEmpty:               nType = DataType::SQLNULL;      break;
120cdf0e10cSrcweir         case adUserDefined:
121cdf0e10cSrcweir         case adPropVariant:
122cdf0e10cSrcweir         case adFileTime:
123cdf0e10cSrcweir         case adChapter:
124cdf0e10cSrcweir         case adIDispatch:
125cdf0e10cSrcweir         case adIUnknown:
126cdf0e10cSrcweir         case adError:
127cdf0e10cSrcweir         case adVariant:
128cdf0e10cSrcweir                                     nType = DataType::OTHER;        break;
129cdf0e10cSrcweir         default:
130cdf0e10cSrcweir             OSL_ENSURE(0,"MapADOType2Jdbc: Unknown Type!");
131cdf0e10cSrcweir             ;
132cdf0e10cSrcweir     }
133cdf0e10cSrcweir     return nType;
134cdf0e10cSrcweir }
135cdf0e10cSrcweir // -------------------------------------------------------------------------
MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine)136cdf0e10cSrcweir DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine)
137cdf0e10cSrcweir {
138cdf0e10cSrcweir     switch (_nType)
139cdf0e10cSrcweir     {
140cdf0e10cSrcweir         case DataType::SMALLINT:        return adSmallInt;          break;
141cdf0e10cSrcweir         case DataType::INTEGER:         return adInteger;           break;
142cdf0e10cSrcweir         case DataType::BIGINT:          return adBigInt;            break;
143cdf0e10cSrcweir         case DataType::FLOAT:           return adSingle;            break;
144cdf0e10cSrcweir         case DataType::DOUBLE:          return adDouble;            break;
145cdf0e10cSrcweir         case DataType::NUMERIC:         return adNumeric;           break;
146cdf0e10cSrcweir         case DataType::DECIMAL:         return adDecimal;           break;
147cdf0e10cSrcweir         case DataType::DATE:            return isJetEngine(_nJetEngine) ? adDate : adDBDate;            break;
148cdf0e10cSrcweir         case DataType::TIME:            return adDBTime;            break;
149cdf0e10cSrcweir         case DataType::TIMESTAMP:       return isJetEngine(_nJetEngine) ? adDate : adDBTimeStamp;       break;
150cdf0e10cSrcweir         case DataType::BOOLEAN:
151cdf0e10cSrcweir         case DataType::BIT:             return adBoolean;           break;
152cdf0e10cSrcweir         case DataType::BINARY:          return adBinary;            break;
153cdf0e10cSrcweir         case DataType::VARCHAR:         return adVarWChar;          break;
154cdf0e10cSrcweir         case DataType::CLOB:
155cdf0e10cSrcweir         case DataType::LONGVARCHAR:     return adLongVarWChar;      break;
156cdf0e10cSrcweir         case DataType::VARBINARY:       return adVarBinary;         break;
157cdf0e10cSrcweir         case DataType::BLOB:
158cdf0e10cSrcweir         case DataType::LONGVARBINARY:   return adLongVarBinary;     break;
159cdf0e10cSrcweir         case DataType::CHAR:            return adWChar;             break;
160cdf0e10cSrcweir         case DataType::TINYINT:         return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break;
161cdf0e10cSrcweir         case DataType::OBJECT:          return adGUID;      break;
162cdf0e10cSrcweir     default:
163cdf0e10cSrcweir         OSL_ENSURE(0,"MapJdbc2ADOType: Unknown Type!");
164cdf0e10cSrcweir             ;
165cdf0e10cSrcweir     }
166cdf0e10cSrcweir     return adEmpty;
167cdf0e10cSrcweir }
168cdf0e10cSrcweir // -----------------------------------------------------------------------------
169cdf0e10cSrcweir const int JET_ENGINETYPE_UNKNOWN    = 0;
170cdf0e10cSrcweir const int JET_ENGINETYPE_JET10      = 1;
171cdf0e10cSrcweir const int JET_ENGINETYPE_JET11      = 2;
172cdf0e10cSrcweir const int JET_ENGINETYPE_JET20      = 3;
173cdf0e10cSrcweir const int JET_ENGINETYPE_JET3X      = 4;
174cdf0e10cSrcweir const int JET_ENGINETYPE_JET4X      = 5;
175cdf0e10cSrcweir const int JET_ENGINETYPE_DBASE3     = 10;
176cdf0e10cSrcweir const int JET_ENGINETYPE_DBASE4     = 11;
177cdf0e10cSrcweir const int JET_ENGINETYPE_DBASE5     = 12;
178cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL30    = 20;
179cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL40    = 21;
180cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL50    = 22;
181cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL80    = 23;
182cdf0e10cSrcweir const int JET_ENGINETYPE_EXCEL90    = 24;
183cdf0e10cSrcweir const int JET_ENGINETYPE_EXCHANGE4  = 30;
184cdf0e10cSrcweir const int JET_ENGINETYPE_LOTUSWK1   = 40;
185cdf0e10cSrcweir const int JET_ENGINETYPE_LOTUSWK3   = 41;
186cdf0e10cSrcweir const int JET_ENGINETYPE_LOTUSWK4   = 42;
187cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX3X  = 50;
188cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX4X  = 51;
189cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX5X  = 52;
190cdf0e10cSrcweir const int JET_ENGINETYPE_PARADOX7X  = 53;
191cdf0e10cSrcweir const int JET_ENGINETYPE_TEXT1X     = 60;
192cdf0e10cSrcweir const int JET_ENGINETYPE_HTML1X     = 70;
193cdf0e10cSrcweir 
isJetEngine(sal_Int32 _nEngineType)194cdf0e10cSrcweir sal_Bool ADOS::isJetEngine(sal_Int32 _nEngineType)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir     sal_Bool bRet = sal_False;
197cdf0e10cSrcweir     switch(_nEngineType)
198cdf0e10cSrcweir     {
199cdf0e10cSrcweir         case JET_ENGINETYPE_UNKNOWN:
200cdf0e10cSrcweir         case JET_ENGINETYPE_JET10:
201cdf0e10cSrcweir         case JET_ENGINETYPE_JET11:
202cdf0e10cSrcweir         case JET_ENGINETYPE_JET20:
203cdf0e10cSrcweir         case JET_ENGINETYPE_JET3X:
204cdf0e10cSrcweir         case JET_ENGINETYPE_JET4X:
205cdf0e10cSrcweir         case JET_ENGINETYPE_DBASE3:
206cdf0e10cSrcweir         case JET_ENGINETYPE_DBASE4:
207cdf0e10cSrcweir         case JET_ENGINETYPE_DBASE5:
208cdf0e10cSrcweir         case JET_ENGINETYPE_EXCEL30:
209cdf0e10cSrcweir         case JET_ENGINETYPE_EXCEL40:
210cdf0e10cSrcweir         case JET_ENGINETYPE_EXCEL50:
211cdf0e10cSrcweir         case JET_ENGINETYPE_EXCEL80:
212cdf0e10cSrcweir         case JET_ENGINETYPE_EXCEL90:
213cdf0e10cSrcweir         case JET_ENGINETYPE_EXCHANGE4:
214cdf0e10cSrcweir         case JET_ENGINETYPE_LOTUSWK1:
215cdf0e10cSrcweir         case JET_ENGINETYPE_LOTUSWK3:
216cdf0e10cSrcweir         case JET_ENGINETYPE_LOTUSWK4:
217cdf0e10cSrcweir         case JET_ENGINETYPE_PARADOX3X:
218cdf0e10cSrcweir         case JET_ENGINETYPE_PARADOX4X:
219cdf0e10cSrcweir         case JET_ENGINETYPE_PARADOX5X:
220cdf0e10cSrcweir         case JET_ENGINETYPE_PARADOX7X:
221cdf0e10cSrcweir         case JET_ENGINETYPE_TEXT1X:
222cdf0e10cSrcweir         case JET_ENGINETYPE_HTML1X:
223cdf0e10cSrcweir             bRet = sal_True;
224cdf0e10cSrcweir             break;
225cdf0e10cSrcweir     }
226cdf0e10cSrcweir     return bRet;
227cdf0e10cSrcweir }
228cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapObjectType2Ado(sal_Int32 objType)229cdf0e10cSrcweir ObjectTypeEnum ADOS::mapObjectType2Ado(sal_Int32 objType)
230cdf0e10cSrcweir {
231cdf0e10cSrcweir     ObjectTypeEnum eType = adPermObjTable;
232cdf0e10cSrcweir     switch(objType)
233cdf0e10cSrcweir     {
234cdf0e10cSrcweir         case PrivilegeObject::TABLE:
235cdf0e10cSrcweir             eType = adPermObjTable;
236cdf0e10cSrcweir             break;
237cdf0e10cSrcweir         case PrivilegeObject::VIEW:
238cdf0e10cSrcweir             eType = adPermObjView;
239cdf0e10cSrcweir             break;
240cdf0e10cSrcweir         case PrivilegeObject::COLUMN:
241cdf0e10cSrcweir             eType = adPermObjColumn;
242cdf0e10cSrcweir             break;
243cdf0e10cSrcweir     }
244cdf0e10cSrcweir     return eType;
245cdf0e10cSrcweir }
246cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapAdoType2Object(ObjectTypeEnum objType)247cdf0e10cSrcweir sal_Int32 ADOS::mapAdoType2Object(ObjectTypeEnum objType)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir     sal_Int32 nType = PrivilegeObject::TABLE;
250cdf0e10cSrcweir     switch(objType)
251cdf0e10cSrcweir     {
252cdf0e10cSrcweir         case adPermObjTable:
253cdf0e10cSrcweir             nType = PrivilegeObject::TABLE;
254cdf0e10cSrcweir             break;
255cdf0e10cSrcweir         case adPermObjView:
256cdf0e10cSrcweir             nType = PrivilegeObject::VIEW;
257cdf0e10cSrcweir             break;
258cdf0e10cSrcweir         case adPermObjColumn:
259cdf0e10cSrcweir             nType = PrivilegeObject::COLUMN;
260cdf0e10cSrcweir             break;
261cdf0e10cSrcweir         default:
262cdf0e10cSrcweir             OSL_ENSURE( false, "ADOS::mapAdoType2Object: privilege type cannot be translated!" );
263cdf0e10cSrcweir             break;
264cdf0e10cSrcweir     }
265cdf0e10cSrcweir     return nType;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir #ifdef DELETE
268cdf0e10cSrcweir #undef DELETE
269cdf0e10cSrcweir #endif
270cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapAdoRights2Sdbc(RightsEnum eRights)271cdf0e10cSrcweir sal_Int32 ADOS::mapAdoRights2Sdbc(RightsEnum eRights)
272cdf0e10cSrcweir {
273cdf0e10cSrcweir     sal_Int32 nRights = 0;
274cdf0e10cSrcweir     if((eRights & adRightInsert) == adRightInsert)
275cdf0e10cSrcweir         nRights |= Privilege::INSERT;
276cdf0e10cSrcweir     if((eRights & adRightDelete) == adRightDelete)
277cdf0e10cSrcweir         nRights |= ::com::sun::star::sdbcx::Privilege::DELETE;
278cdf0e10cSrcweir     if((eRights & adRightUpdate) == adRightUpdate)
279cdf0e10cSrcweir         nRights |= Privilege::UPDATE;
280cdf0e10cSrcweir     if((eRights & adRightWriteDesign) == adRightWriteDesign)
281cdf0e10cSrcweir         nRights |= Privilege::ALTER;
282cdf0e10cSrcweir     if((eRights & adRightRead) == adRightRead)
283cdf0e10cSrcweir         nRights |= Privilege::SELECT;
284cdf0e10cSrcweir     if((eRights & adRightReference) == adRightReference)
285cdf0e10cSrcweir         nRights |= Privilege::REFERENCE;
286cdf0e10cSrcweir     if((eRights & adRightDrop) == adRightDrop)
287cdf0e10cSrcweir         nRights |= Privilege::DROP;
288cdf0e10cSrcweir 
289cdf0e10cSrcweir     return nRights;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir // -----------------------------------------------------------------------------
mapRights2Ado(sal_Int32 nRights)292cdf0e10cSrcweir sal_Int32 ADOS::mapRights2Ado(sal_Int32 nRights)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir     sal_Int32 eRights = adRightNone;
295cdf0e10cSrcweir 
296cdf0e10cSrcweir     if((nRights & Privilege::INSERT) == Privilege::INSERT)
297cdf0e10cSrcweir         eRights |= adRightInsert;
298cdf0e10cSrcweir     if((nRights & Privilege::DELETE) == Privilege::DELETE)
299cdf0e10cSrcweir         eRights |= adRightDelete;
300cdf0e10cSrcweir     if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
301cdf0e10cSrcweir         eRights |= adRightUpdate;
302cdf0e10cSrcweir     if((nRights & Privilege::ALTER) == Privilege::ALTER)
303cdf0e10cSrcweir         eRights |= adRightWriteDesign;
304cdf0e10cSrcweir     if((nRights & Privilege::SELECT) == Privilege::SELECT)
305cdf0e10cSrcweir         eRights |= adRightRead;
306cdf0e10cSrcweir     if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
307cdf0e10cSrcweir         eRights |= adRightReference;
308cdf0e10cSrcweir     if((nRights & Privilege::DROP) == Privilege::DROP)
309cdf0e10cSrcweir         eRights |= adRightDrop;
310cdf0e10cSrcweir 
311cdf0e10cSrcweir     return eRights;
312cdf0e10cSrcweir }
313cdf0e10cSrcweir // -----------------------------------------------------------------------------
getField(ADORecordset * _pRecordSet,sal_Int32 _nColumnIndex)314cdf0e10cSrcweir WpADOField ADOS::getField(ADORecordset* _pRecordSet,sal_Int32 _nColumnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir     if ( !_pRecordSet )
317cdf0e10cSrcweir         return WpADOField();
318cdf0e10cSrcweir 
319cdf0e10cSrcweir     ADOFields* pFields  = NULL;
320cdf0e10cSrcweir     _pRecordSet->get_Fields(&pFields);
321cdf0e10cSrcweir     WpOLEAppendCollection<ADOFields, ADOField, WpADOField>  aFields(pFields);
322cdf0e10cSrcweir     if(_nColumnIndex <= 0 || _nColumnIndex > aFields.GetItemCount())
323cdf0e10cSrcweir         ::dbtools::throwInvalidIndexException(NULL);
324cdf0e10cSrcweir     WpADOField aField(aFields.GetItem(_nColumnIndex-1));
325cdf0e10cSrcweir     if(!aField.IsValid())
326cdf0e10cSrcweir         ::dbtools::throwInvalidIndexException(NULL);
327cdf0e10cSrcweir     return aField;
328cdf0e10cSrcweir }
329cdf0e10cSrcweir // -----------------------------------------------------------------------------
330