Solved

What is GetDefaultCType(SQLType); ??

Posted on 2002-06-18
3
508 Views
Last Modified: 2008-02-07
Hi,

Okay, MSDN, Using SQLBindCol...
I need to do exactly what they demonstrate at the bottom, I am doing a "SELECT * FROM xyz", my program is for dumping record for archive purposes, so I need to ensure it won't break in the furture, thus is needs a "*" to handle new columns added later.

However, the MSDN does not appear to tell us, either ion the CD's on MS website what GetDefaultCType(SQLType); routine looks like. I personally don't undertand what else it can return apart from a "C" type id, like SQL_C_CHAR, as things like SQLCHAR are typedefs not identifiers.

None the less, I need to get this working quite soon, as it was due last Friday, so if anybody can shed some light on this, or maybe post the code for this routine, I'd be most grateful.

Thankx,
Mark
0
Comment
Question by:mh2
  • 2
3 Comments
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 7092087
GetDefaultCType is not an API function.  It is odd, but not all that unusual that the example code on that pages uses an undefined function -- it is after all a seried of descriptive fragments.  The comments in the code say:

  // Determine the column's SQL type. GetDefaultCType contains a switch
   // statement that returns the default C type for each SQL type.
  CTypeArray[i] = GetDefaultCType(SQLType);

in which they describe what you will need to do to write that function yourself -- create a switch statement that converte each expected SQL_ data type into its equivallent C data type.

Note that I have written code that simply converts all column data into strings of text (that is, it requests string data type output for each column.  It is very simple and you can insert the data back into a database also using a standard string (the only exceptions are BLOBS and such).  Would that work for you?

-- Dan
0
 
LVL 3

Author Comment

by:mh2
ID: 7092116
Hi,

Yes, I realized we had to write it, but when I was doing this, it didn't make sense, as I was aware of say a SQL_C_TYPE identifier, like SQL_C_SLONG, and SQL typedef, like SQLINTEGER. So it didn't make sense, you cant map a constant identifier to a typedef!?!

I found now as I was trying unsuccessfully to bind a date parameter there is also a SQL type identifier, like SQL_INTEGER (as opposed to the typedef SQLINTEGER )assuming one maps this identifier to the SQL_INTEGER => SQL_C_SLONG?

In the end, I simply bound all columns as SQL_C_CHAR, and the driver converted it to a string for me, which worked fine for me.

Thanks for the input!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7093129
Just out of mild curiousity... why did you stick me with a B?  I'm trying to maintain a 4.0 GPA.  I'd like to know so that in the future I can provide really really really really really really really really good comments so that I'll get all As.  Thanks for responding!

-- Dan
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

808 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