Cannot #include sql.h or sqlext.h

I am writing an ODBC module for a C++ program using straight Win32 API calls.  IntelliSense seems to know all the functions and data types with nothing but windows.h #include'd, but it won't compile like that.  When I #include sql.h or sqlext.h, I get a bunch of syntax errors when I try to compile.  Missing ; before *, undeclared identifiers, redefinitions, too many initializers, etc. etc. etc.  They're definetly coming from the headers, since my project only has a stubbed constructor and destructor at this point.

What is the correct way to include the libraries you need for ODBC functions?
LVL 14
cuziyqAsked:
Who is Participating?
 
ikeworkConnect With a Mentor Commented:
did you include <windows.h> efore <sql.h> ?
1
 
Ashish PatelCommented:
use #include <sql.h> or #include "sql.h" depending on the path settings.
0
 
cuziyqAuthor Commented:
That's what I did.  It's definetly trying to parse the header file.  It's just claiming that the header has a bunch of errors.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
Ashish PatelCommented:
if its saying that headers have bunch of errors that means it found the header. Can you please post the first error line
0
 
cuziyqAuthor Commented:
The errors are as follows:

c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(275): error C2146: syntax error : missing ';' before identifier 'Data1'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(276): error C2146: syntax error : missing ';' before identifier 'Data2'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(277): error C2146: syntax error : missing ';' before identifier 'Data3'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(278): error C2146: syntax error : missing ';' before identifier 'Data4'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(137): error C2146: syntax error : missing ';' before identifier 'SQLHWND'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(137): error C2501: 'SQLHWND' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(278): error C2501: 'tagSQLGUID::BYTE' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(275): error C2501: 'tagSQLGUID::Data1' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(276): error C2501: 'tagSQLGUID::Data2' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(277): error C2501: 'tagSQLGUID::Data3' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(278): error C2501: 'tagSQLGUID::Data4' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(275): error C2501: 'tagSQLGUID::DWORD' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(276): error C2501: 'tagSQLGUID::WORD' : missing storage-class or type specifiers
c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\SqlTypes.h(277): error C2501: 'tagSQLGUID::WORD' : missing storage-class or type specifiers

I've even tried replacing this file with the copy from the CD.  Still doesn't work.
0
 
Ashish PatelCommented:
OOps you are missing the sime-colon ";" after the end of line..please check for functions or variables used from SqlTypes.h into your program.
0
 
cuziyqAuthor Commented:
This header is one supplied by Microsoft, and I have not changed it in any way.  It *shouldn't* contain any errors.

It can't possibly be my program either, as this is all I have:

#include <sql.h>

class SQLobj
{
public:
     SQLobj();
     ~SQLobj();
};

SQLobj::SQLobj()
{
}

SQLobj::~SQL()
{
}
0
 
cuziyqAuthor Commented:
I can't believe this.  I HATE when this happens.  ikework, you get the points.  <windows.h> is included in other files in the project (which is probably why IntelliSense is working), but you were absolutely right; #include <windows.h> in this header fixes the problem.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.