Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Getting ADO Column Type

Posted on 1999-07-28
Medium Priority
Last Modified: 2013-12-03
I'm writing to an Access db using ado under VC6 and I need to update a field. I need to determine the field's variant type before setting the field (or else ADO will cause an exception). I'm guessing this information might come from the OpenSchema call in Recordset. This is where I'm getting the table and column names. If someone could give a quick example it would be helpful (It could even be from another language since the calls would be similar).
Question by:forloop
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

rayb earned 280 total points
ID: 1403967
You can open the table with a recordset, using the following syntax:

rs->Open ("Employees", CONNECTION_STRING, adOpenStatic, adLockReadOnly, -1)

Where "Employees" is the table name, then you can access the field type like so:


Use 1 or 0 or 2, whatever...  Then you need to map the Type which is a value from the DataTypeEnum to a VARTYPE.

If this is an operation you are going to do repeatedly it's best to do it during program initialization and keep the info cached.



Expert Comment

ID: 1403968

Change this:
rs->Open ("Employees", CONNECTION_STRING, adOpenStatic, adLockReadOnly, -1)

To this:
rs->Open (_variant_t(L"Employees"), _variant_t(CONNECTION_STRING), adOpenStatic, adLockReadOnly, -1)


Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question