Solved

What is GetDefaultCType(SQLType); ??

Posted on 2002-06-18
3
522 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
[X]
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
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

705 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