Solved

What is GetDefaultCType(SQLType); ??

Posted on 2002-06-18
3
477 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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now