Solved

What is GetDefaultCType(SQLType); ??

Posted on 2002-06-18
3
516 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

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 …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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.

749 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