Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is GetDefaultCType(SQLType); ??

Posted on 2002-06-18
3
Medium Priority
?
563 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 300 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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  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 …
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

610 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