?
Solved

Cannot #include sql.h or sqlext.h

Posted on 2007-09-28
8
Medium Priority
?
1,968 Views
Last Modified: 2013-12-14
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?
0
Comment
Question by:cuziyq
  • 4
  • 3
8 Comments
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 19980185
use #include <sql.h> or #include "sql.h" depending on the path settings.
0
 
LVL 14

Author Comment

by:cuziyq
ID: 19980207
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
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 19980217
if its saying that headers have bunch of errors that means it found the header. Can you please post the first error line
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 14

Author Comment

by:cuziyq
ID: 19980309
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
 
LVL 23

Expert Comment

by:Ashish Patel
ID: 19980333
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
 
LVL 14

Author Comment

by:cuziyq
ID: 19980379
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
 
LVL 20

Accepted Solution

by:
ikework earned 375 total points
ID: 19981356
did you include <windows.h> efore <sql.h> ?
1
 
LVL 14

Author Comment

by:cuziyq
ID: 19981817
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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 my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
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.

840 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