Re: Getting the data type of a column
- From: "Bob Barrows [MVP]" <reb01501@xxxxxxxxxxxxxxx>
- Date: Tue, 17 Apr 2007 07:11:49 -0400
Kannan wrote:
Hi,
I am writing a program in C++ to get data from an MS Access mdb file.
What I need is to get is the data type of a column, given the table
name and the column name. How will I do it C++? I think something
can be done by using
rec = conn->OpenSchema(adSchemaColumns, vtCriteria, vtMissing);
//where vtCriteria is {Empty, Empty, TableName, Empty}
but when I try to get the column data type as below, it fails at
GetItem() call fails.
DataTypeEnum dataType;
rec->Fields->GetItem("ColumnName")->get_Type( &dataType );
I know that from the result of a SQL select query I can call
"get_Type()" on the column field and get the data type. But what I
need to know how to get the properties (including the datatype) of a
column in a table.
I am coding in C++ not in VB or C#.
It appears you have failed to read the documentation, which can be found
here:
http://msdn.microsoft.com/library/en-us/ado270/htm/mdmscadoapireference.asp
If you read the documentation for the SchemaEnum
(http://msdn.microsoft.com/library/en-us/ado/html/21c97651-297f-469f-b5b5-c48af72b62a8.asp?frame=true),
you would have seen that the recordset returned by adSchemaColumns does not
provide column datatype information.
In fact, OpenSchema seems to be useless for providing this type of
information. If you don't wish to query the field types of a recordset
opened on a table, your only recourse is to use ADOX.
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
.
- Follow-Ups:
- Re: Getting the data type of a column
- From: Kannan
- Re: Getting the data type of a column
- Prev by Date: Re: Recordset Field - modifiable default values?
- Next by Date: Re: Getting the data type of a column
- Previous by thread: Recordset Field - modifiable default values?
- Next by thread: Re: Getting the data type of a column
- Index(es):
Relevant Pages
|
|