Solved

C++ & Databases

Posted on 2004-10-11
17
1,242 Views
Last Modified: 2010-05-18
At the moment I use Delphi and have been for the past 3 years, however I'm trying to get into C++ and write cross-platform code without relying on IDE's and platform-specific API/Drivers.
 
In Delphi I use something like:
 
ADOConnection.Close;
ADOConnection.ConnectionString := 'Provider=SQLOLEDB.1;Password=password;User ID=scheme;Data Source=tech06;Initial Catalog=demo';
ADOConnection.Connect;
ADOQuery.Connection := ADOConnection;
ADOQuery.Close;
ADOQuery.SQL.Text := "select * from scheme.slcustm";
ADOQuery.Open;

while not ADODatasource_Cust.Dataset.EOF do
begin
  ShowMessage(ADODatasource_Cust.Dataset.FieldByName('accountid').AsString);
  ADODatasource_Cust.Dataset.Next;
end

That example isn't very real-world but illustrates how to just grab a dataset, and iterate through it. The syntax is very similar for Oracle/MySQL too. I wanted to find a solution that would allow something just as easy/rapid in C++.

Any suggestions? I'm already looking at SourcePro from RogueWave. But as I'm a single developer learning C++ in my own time on my own budget I don't really have the funds for commercial products.
0
Comment
Question by:Narusegawa
  • 8
  • 8
17 Comments
 
LVL 1

Expert Comment

by:gseidman
ID: 12281108
If you want cross-platform, you need to choose some cross-platform API. I know of two, though there may be more. First off, an implementation of ODBC (actually, two: iODBC and unixODBC) is available for any unix-like OS (including MacOS X). ODBC is a C API, but it is moderately easy to wrap the annoying parts in C++ classes. I should still have some simple code you could build on, if you like. The other API is Qt (see http://www.trolltech.com/ ), which is available for MacOS X, Windows, and Unix/X11 (i.e. anything unix-like with an X11 server).

If you are strapped for funds and you are targetting Windows, Qt will not help you. The X11 and MacOS X versions are licensed under both the GNU GPL and a (somewhat costly) commercial license, but the Windows version is only available under the commercial license (there exists an older non-commercial version that does not include the database API, as well as a more recent non-commercial version that may or may not but is hard to find).

Both APIs have their unique failings, but the most important problem with both is that drivers for commercial databases are largely unavailable for non-Windows platforms. If you really need cross-platform compatibility with any and all databases, you will want to use Java and JDBC. JDBC drivers are available for essentially all RDBMSs, and almost all are pure Java and, therefore, cross-platform. It is possible to do your database work in Java and any other part of your program in C++, but you can expect it to be a pain.
0
 
LVL 4

Expert Comment

by:pankajtiwary
ID: 12283539
You can download the client library distribution from Oracle/MySql websites. The development environment for oracle is called Pro*C. Its is a little bit different than normal C++ because you can write SQL statements inside your C++ program. Then Orcale Pro*C (which is actually a precompiler) converts your code to a pure C++ code substituting the Sqllib library calls in place of the SQL statements. You can then compile it using normal C++ compiler and link it with the sqllib library. This will solve your purpose.

In case of MySql, this is fairly easy. You can download the client library which contains all the compiled functions required for your transactions ( e.g mysql_connect(), mysql_query() and mysql_close() ). You can  simply include the header files which has the declarations for those functions and just link it with the library provided with. This will create the executable and you can do whatever you want to do with the MySql database.

Cheer!!!
0
 

Author Comment

by:Narusegawa
ID: 12284498
gseidman: That's a great explanation. I was looking at ODBC but being new to C++ I have started to do much with Classes yet. You 'simple code' would be great for helping me get a start on it. I'm not sure how ODBC differentiates between what drivers it loads. i.e. You tell it MSSQL and it finds the driver? You tell it mySQL and it finds it's relevant driver. I do know that FreeTDS for Linux can talk to MSSQL, I've got that working from within a PHP site. It'd be nice to be able to use a single code base to support as many databases as I can.

The only reason I even need MSSQL as part of what I want to be able to do is that 80% of our customers run Sage on SQL 2000 servers. So to make it worthwhile for my boss to consider any C++ development in addition to Delphi I need to be able to connect to that aswell, but without too many changes in the code (which takes up 'chargable' time).

I figure from all of this that ODBC really is the best way, and ODBC is implemented in Windows by default, and with unixODBC and iODBC for Linux.
0
 
LVL 1

Accepted Solution

by:
gseidman earned 500 total points
ID: 12285826
I'll dig up my code. It's from my Master's research from some time ago (so I have to go searching for it), and I developed it on Linux against unixODBC, which I recommend over iODBC. The only reason I mentioned iODBC is that it comes preinstalled on MacOS X (10.2 or later, I think, but definitely 10.2). The way it works is that one creates DSNs (Data Store Names, I think) using an administration tool (or by editing config files manually), and the DSN designates the driver and database name. The program refers only to the DSN, so the specific database can be swapped without recompilation.

Connecting to an SQL Server database from Linux may require purchasing a driver; a free driver exists for iODBC which may or may not work well and may or may not work with unixODBC. For unixODBC driver availability see http://www.unixodbc.org/drivers.html and for iODBC see http://www.sqlsummit.com/ODBCVend.htm . You will need to do some testing to make sure everything works on the Linux end.

You will obviously need to make sure that the SQL commands/queries you use to interact with the database do not use any RDBMS-specific extensions; no two RDBMSs implement exactly the same dialect of SQL, and you will need to make sure that all SQL statements are compatible with all targeted RDBMSs.

Anyhow, I'll dig up that code (later today, I hope) and post it.
0
 

Author Comment

by:Narusegawa
ID: 12286610
Thanks ever so much, that'd be most useful! I avoid database specific commands when I can anyway. If something is awkard to do I return it to the program and do it locally rather than on the database.
0
 
LVL 1

Expert Comment

by:gseidman
ID: 12287021
Okay, here's the odbcutil library I wrote. It's pretty rudimentary, but it should help you get started. You will still need to learn some of the basic ODBC API (particularly the SQLBindCol() and SQLBindParameter() functions), but the really annoying stuff about setting up and cleaning up is layered away. Note that the odbcutil.[CH] files are really just C, but DBstatement is C++. In my next comment I will include a small sample program that uses this library.

//odbcutil.H
#ifndef ODBCUTIL_H
#define ODBCUTIL_H
#include <sqltypes.h>
#include <sqlext.h>
#include <sql.h>

void closeConnection(SQLHDBC dbchandle);
void cleanup(SQLHDBC dbchandle, SQLHENV odbcenv);
void diagErrorDB(SQLHDBC dbchandle);
void diagErrorStmt(SQLHANDLE stmthandle);
void diagErrorAndExit(SQLHDBC dbchandle, SQLHENV odbcenv);
SQLRETURN allocConn(SQLHENV odbcenv, SQLHDBC *dbchandle);
SQLRETURN allocEnvAndConn(SQLHENV *odbcenv, SQLHDBC *dbchandle);

#endif //ODBCUTIL_H

//odbcutil.C
#include <stdio.h>
#include <stdlib.h>
#include <sqltypes.h>
#include <sqlext.h>
#include <sql.h>
#include "odbcutil.H"

void
closeConnection(SQLHDBC dbchandle) {
  SQLDisconnect(dbchandle);
  SQLFreeHandle(SQL_HANDLE_DBC, dbchandle);
}

void
cleanup(SQLHDBC dbchandle, SQLHENV odbcenv) {
  closeConnection(dbchandle);
  SQLFreeHandle(SQL_HANDLE_ENV, odbcenv);
}

void
diagErrorDB(SQLHDBC dbchandle) {
  SQLCHAR     status[10];
  SQLINTEGER  errorcode;
  SQLSMALLINT msglen;
  SQLCHAR     errormsg[200];

  SQLGetDiagRec(SQL_HANDLE_DBC, dbchandle, 1,
      status, &errorcode, errormsg, 100, &msglen);
  printf("[%s] %s (%d)\n", status, errormsg, errorcode);
}

void
diagErrorStmt(SQLHANDLE stmthandle) {
  SQLCHAR     status[10];
  SQLINTEGER  errorcode;
  SQLSMALLINT msglen;
  SQLCHAR     errormsg[200];

  SQLGetDiagRec(SQL_HANDLE_STMT, stmthandle, 1,
      status, &errorcode, errormsg, 100, &msglen);
  printf("[%s] %s (%d)\n", status, errormsg, errorcode);
}

void
diagErrorAndExit(SQLHDBC dbchandle, SQLHENV odbcenv) {
  diagErrorDB(dbchandle);
  cleanup(dbchandle, odbcenv);
  exit(1);
}

/* returns SQL_SUCCESS on success, retcode on fail */
SQLRETURN
allocConn(SQLHENV odbcenv, SQLHDBC *dbchandle) {
  // 2. allocate connection handle, set timeout
  SQLRETURN retcode = SQLAllocHandle(SQL_HANDLE_DBC, odbcenv, dbchandle);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    printf("Error AllocHDB %d\n", retcode);
    return retcode;
  }
  SQLSetConnectAttr(*dbchandle, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0);
}

/* returns SQL_SUCCESS on success, retcode on fail */
SQLRETURN
allocEnvAndConn(SQLHENV *odbcenv, SQLHDBC *dbchandle) {
  SQLRETURN   retcode; // result of functions

  // 1. allocate Environment handle and register version
  retcode=SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, odbcenv);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    printf("Error AllocHandle\n");
    return retcode;
  }
  retcode =
    SQLSetEnvAttr(*odbcenv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    printf("Error SetEnv\n");
    SQLFreeHandle(SQL_HANDLE_ENV, *odbcenv);
    return retcode;
  }
  // 2. allocate connection handle, set timeout
  retcode = allocConn(*odbcenv, dbchandle);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    SQLFreeHandle(SQL_HANDLE_ENV, *odbcenv);
    return retcode;
  }
  SQLSetConnectAttr(*dbchandle, SQL_LOGIN_TIMEOUT, (SQLPOINTER *)5, 0);
  return SQL_SUCCESS;
}

//dbstatement.H
#ifndef DBSTATEMENT_H
#define DBSTATEMENT_H
#include <sqltypes.h>
#include <sqlext.h>
#include <sql.h>
#include <stdio.h>

class DBstatement {
  private:
    const bool owner;
  protected:
    SQLHANDLE stmthandle; // statement handle
    SQLHDBC   dbchandle;  // DB handle, need it to be handy
    SQLINTEGER  NTSp;
    DBstatement(SQLHDBC DBChandle, const char *stmt,
        bool ownconnection = false);
    DBstatement(SQLHDBC DBChandle,
        bool ownconnection = false);
    inline SQLRETURN exec() { return SQLExecute(stmthandle); }
    SQLRETURN exec(SQLCHAR *stmt);
  public:
    bool diag(SQLRETURN retcode);
    virtual ~DBstatement();
};

#endif //DBSTATEMENT_H

//dbstatement.C
#ifndef NDEBUG
#include <iostream>
#endif
#include <sqltypes.h>
#include <sqlext.h>
#include <sql.h>
#include <stdlib.h>
#include <stdio.h>
#include "odbcutil.H"
#include "dbstatement.H"

DBstatement::DBstatement(SQLHDBC DBChandle, const char *stmt,
    bool ownconnection) :
dbchandle(DBChandle), owner(ownconnection),
NTSp(SQL_NTS) {
  SQLRETURN   retcode; // result of functions

  retcode = SQLAllocHandle(SQL_HANDLE_STMT, DBChandle, &stmthandle);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    exit(1);
  }
  retcode = SQLPrepare(stmthandle, (SQLCHAR *)stmt, SQL_NTS);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    exit(1);
  }
}

DBstatement::DBstatement(SQLHDBC DBChandle, bool ownconnection) :
dbchandle(DBChandle), owner(ownconnection),
NTSp(SQL_NTS) {
  SQLRETURN   retcode; // result of functions

  retcode = SQLAllocHandle(SQL_HANDLE_STMT, DBChandle, &stmthandle);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    exit(1);
  }
}

DBstatement::~DBstatement() {
  SQLFreeHandle(SQL_HANDLE_STMT, stmthandle);
  if (owner)
    closeConnection(dbchandle);
}

SQLRETURN
DBstatement::exec(SQLCHAR *stmt) {
#ifndef NDEBUG
  std::cerr << "Executing SQL: " << stmt << std::endl;
#endif
  return SQLExecDirect(stmthandle, stmt, SQL_NTS);
}

bool
DBstatement::diag(SQLRETURN retcode) {
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    //diagErrorDB(dbchandle);
    diagErrorStmt(stmthandle);
    //SQLCancel(stmthandle);
    return true;
  } else {
    //printf("No error.\n");
    return false;
  }
}


0
 
LVL 1

Expert Comment

by:gseidman
ID: 12287079
Here is the example program, as promised:

//getcount.H
#ifndef GETCOUNT_H
#define GETCOUNT_H
#include "dbstatement.H"
#include <sqltypes.h>

class GetCount : public DBstatement {
  private:
    static const char *stmt;
    SQLINTEGER errorcode, num;

  public:
    GetCount(SQLHDBC dbchandle);
    int count(const char *table);
};

#endif //GETCOUNT_H

//getcount.C
#include <string>
#include "getcount.H"

const char *GetCount::stmt = "SELECT COUNT(*) FROM ";

GetCount::GetCount(SQLHDBC dbchandle) : DBstatement(dbchandle) {
  SQLBindCol(stmthandle, 1, SQL_C_ULONG, &num, 150, &errorcode);
}

int
GetCount::count(const char *table) {
  SQLRETURN retcode;
  std::string st(stmt);

  st += table;
  retcode = exec((SQLCHAR*)st.c_str());
  if (diag(retcode)) {
    printf("While attempting to count %s.\n", table);
    return -1;
  } else {
    SQLINTEGER  nrows;
    SQLSMALLINT ncols;

    retcode = SQLNumResultCols(stmthandle, &ncols);
    if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
      fprintf(stderr, "Error in NumResultCols %d\n", retcode);
      SQLCancel(stmthandle);
      return -1;
    }
    if (ncols!=1) {
      fprintf(stderr, "Number of Columns %d\n", ncols);
      SQLCancel(stmthandle);
      return -1;
    }
    retcode = SQLRowCount(stmthandle, &nrows);
    if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
      fprintf(stderr, "Error in RowCount %d\n", retcode);
      SQLCancel(stmthandle);
      return -1;
    }
    if (nrows!=1) {
      fprintf(stderr, "Number of Rows %d\n", nrows);
      SQLCancel(stmthandle);
      return -1;
    }
    if ((retcode=SQLFetch(stmthandle)) != SQL_NO_DATA) {
      return num;
    } else {
      fprintf(stderr, "No data?!?\n");
      SQLCancel(stmthandle);
      return -1;
    }

  }
}

//main.C
#include "odbcutil.H"
#include "getcount.H"
#include <stdio.h>
#include <math.h>

int
main(int argc, char **argv) {
  SQLHENV     odbcenv; // ODBC environment handle
  SQLHDBC     dbchandle; // connection handle
  SQLRETURN   retcode; // result of functions
  SQLINTEGER  nrows;
  SQLSMALLINT ncols;
  GetCount    *cnt;

  if (argc!=2) {
    fprintf(stderr, "Usage: %s <tablename>\n", argv[0]);
    return 1;
  }
  retcode = allocEnvAndConn(&odbcenv, &dbchandle);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    fprintf(stderr, "ODBC init failed\n");
    return 1;
  }
  retcode = SQLConnect(dbchandle,
      (SQLCHAR*)"DSN", SQL_NTS,
      (SQLCHAR*)"username", SQL_NTS,
      (SQLCHAR*)"password", SQL_NTS);
  if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO)) {
    fprintf(stderr, "ODBC connect failed\n");
    return 1;
  }
  cnt = new GetCount(dbchandle);
  printf("Table %s has %d rows.\n", argv[1], cnt->count(argv[1]));
  delete cnt;
  cleanup(dbchandle, odbcenv);
}

0
 

Author Comment

by:Narusegawa
ID: 12287372
Using Dev-C++ I get the following when trying to compile main.c after adding it (and all the other files) to a new project.

Compiler: Default compiler
Building Makefile: "D:\C++\ODBCTest\Makefile.win"
Executing  make...
make.exe -f "D:\C++\ODBCTest\Makefile.win" all
g++.exe -c main.c -o main.o -I"C:/GTK/INCLUDE"  -I"C:/GTK/INCLUDE/GTK-2.0"  -I"C:/GTK/INCLUDE/GLIB-2.0"  -I"C:/GTK/INCLUDE/PANGO-1.0"  -I"C:/GTK/INCLUDE/ATK-1.0"  -I"C:/GTK/INCLUDE/GTKGLEXT-1.0"  -I"C:/GTK/LIB/GTK-2.0/INCLUDE"  -I"C:/GTK/LIB/GLIB-2.0/INCLUDE"  -I"C:/GTK/LIB/GTKGLEXT-1.0/INCLUDE"  -I"C:/GTK/INCLUDE/LIBGLADE-2.0"  -I"C:/GTK/INCLUDE/LIBXML2"  -I"C:/Program Files/Dev-Cpp/include/c++"  -I"C:/Program Files/Dev-Cpp/include/c++/mingw32"  -I"C:/Program Files/Dev-Cpp/include/c++/backward"  -I"C:/Program Files/Dev-Cpp/include"  -I"D:/C++/ODBCTest"  

In file included from odbcutil.H:3,
                 from main.c:1:
C:/Program Files/Dev-Cpp/include/sqltypes.h:17: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:18: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:24: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:25: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:26: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:27: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:29: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:34: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:36: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:37: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:50: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:51: error: syntax error before `;'

   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:71: error: syntax error before `;'
   token
C:/Program Files/Dev-Cpp/include/sqltypes.h:90: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:91: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:94: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:95: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:96: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:100: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:101: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:102: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.

C:/Program Files/Dev-Cpp/include/sqltypes.h:103: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:104: error: 'SQLUSMALLINT' is used
   as a type, but is not defined as a type.
C:/Program Files/Dev-Cpp/include/sqltypes.h:105: error: 'SQLUINTEGER' is used
   as a type, but is not defined as a type.

In file included from C:/Program Files/Dev-Cpp/include/sqlext.h:7,
                 from odbcutil.H:4,
                 from main.c:1:
C:/Program Files/Dev-Cpp/include/sql.h:346: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:346: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:348: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:348: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:349: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:349: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:349: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:351: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:351: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:352: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:352: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:357: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:358: error: type specifier omitted for
   parameter `SQLCHAR'

C:/Program Files/Dev-Cpp/include/sql.h:358: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:360: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:360: error: syntax error before `*'
   token

C:/Program Files/Dev-Cpp/include/sql.h:362: error: type specifier omitted for

   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:362: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:363: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:364: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:364: error: type specifier omitted for
   parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sql.h:364: error: type specifier omitted for
   parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sql.h:365: error: type specifier omitted for

   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:365: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:366: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:366: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:367: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:367: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:368: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:368: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:368: error: syntax error before `*'
   token

C:/Program Files/Dev-Cpp/include/sql.h:369: error: type specifier omitted for

   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:369: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:370: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:370: error: type specifier omitted for
   parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sql.h:372: error: type specifier omitted for

   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:372: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:373: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:374: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:374: error: type specifier omitted for
   parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sql.h:375: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:375: error: type specifier omitted for
   parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sql.h:376: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:376: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:376: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:377: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:377: error: syntax error before `*'

   token
C:/Program Files/Dev-Cpp/include/sql.h:378: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:378: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:379: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:379: error: type specifier omitted for
   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:379: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:381: error: type specifier omitted for
   parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sql.h:381: error: type specifier omitted for
   parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sql.h:381: error: syntax error before `*'
   token

C:/Program Files/Dev-Cpp/include/sql.h:382: error: type specifier omitted for

   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:382: error: type specifier omitted for
   parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sql.h:382: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:384: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:384: error: type specifier omitted for
   parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sql.h:384: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:384: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:385: error: `SQLHDESC' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:385: error: `SQLHDESC' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:385: error: initializer list being
   treated as compound expression
C:/Program Files/Dev-Cpp/include/sql.h:386: error: type specifier omitted for
   parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sql.h:388: error: type specifier omitted for
   parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sql.h:389: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:390: error: `SQLHDESC' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:390: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sql.h:390: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sql.h:390: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sql.h:391: error: `SQLHDESC' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:391: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sql.h:391: error: `SQLCHAR' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:391: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sql.h:393: error: type specifier omitted for
   parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sql.h:393: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:394: error: type specifier omitted for
   parameter `SQLHANDLE'

C:/Program Files/Dev-Cpp/include/sql.h:394: error: type specifier omitted for

   parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sql.h:394: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:395: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:396: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:397: error: type specifier omitted for
   parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sql.h:398: error: `SQLHDESC' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:398: error: syntax error before `,'

   token
C:/Program Files/Dev-Cpp/include/sql.h:398: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sql.h:398: error: syntax error before `)'
   token
C:/Program Files/Dev-Cpp/include/sql.h:398: error: initializer list being
   treated as compound expression
C:/Program Files/Dev-Cpp/include/sql.h:399: error: `SQLHDESC' was not declared
   in this scope
C:/Program Files/Dev-Cpp/include/sql.h:399: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sql.h:400: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sql.h:400: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sql.h:401: error: type specifier omitted for
   parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sql.h:402: error: type specifier omitted for
   parameter `SQLPOINTER'
In file included from odbcutil.H:4,
                 from main.c:1:
C:/Program Files/Dev-Cpp/include/sqlext.h:1184: error: type specifier omitted
   for parameter `SQLHWND'
C:/Program Files/Dev-Cpp/include/sqlext.h:1184: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1184: error: syntax error before `*'

   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1185: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1185: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1186: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1186: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1187: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1187: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1187: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1188: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1188: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1188: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1189: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1189: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1189: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1190: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1190: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1192: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1192: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1194: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1194: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1194: error: syntax error before `*'

   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1195: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1195: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1196: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1196: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1197: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1197: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1198: error: type specifier omitted
   for parameter `SQLUSMALLINT'

C:/Program Files/Dev-Cpp/include/sqlext.h:1198: error: type specifier omitted

   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1198: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1199: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1199: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1200: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1200: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlext.h:1200: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1201: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1201: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1201: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlext.h:1202: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1202: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlext.h:1203: error: syntax error before `('
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1204: error: syntax error before `('
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1205: error: `LPWSTR' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlext.h:1205: error: `LPWSTR' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlext.h:1205: error: initializer list being
   treated as compound expression
C:/Program Files/Dev-Cpp/include/sqlext.h:1207: error: syntax error before `('
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1208: error: redefinition of `int
   DWORD'
C:/Program Files/Dev-Cpp/include/sqlext.h:1203: error: `int DWORD' previously
   declared here
C:/Program Files/Dev-Cpp/include/sqlext.h:1208: error: syntax error before `('
   token
C:/Program Files/Dev-Cpp/include/sqlext.h:1211: error: type specifier omitted
   for parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sqlext.h:1211: error: type specifier omitted
   for parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sqlext.h:1211: error: syntax error before `*'
   token
In file included from C:/Program Files/Dev-Cpp/include/sqlext.h:1214,
                 from odbcutil.H:4,
                 from main.c:1:
C:/Program Files/Dev-Cpp/include/sqlucode.h:22: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:22: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:24: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:24: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:25: error: type specifier omitted

   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:25: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:25: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:25: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:26: error: type specifier omitted

   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:26: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:26: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:27: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:27: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:27: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:28: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:28: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:30: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:30: error: syntax error before `*'
   token

C:/Program Files/Dev-Cpp/include/sqlucode.h:32: error: type specifier omitted

   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:32: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:34: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:34: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:34: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:35: error: type specifier omitted
   for parameter `SQLUSMALLINT'

C:/Program Files/Dev-Cpp/include/sqlucode.h:36: error: type specifier omitted

   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:36: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:36: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:37: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:37: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:37: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:38: error: type specifier omitted
   for parameter `SQLHWND'

C:/Program Files/Dev-Cpp/include/sqlucode.h:38: error: type specifier omitted

   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:38: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:39: error: type specifier omitted
   for parameter `SQLHWND'
C:/Program Files/Dev-Cpp/include/sqlucode.h:39: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:40: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:40: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:40: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:41: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:42: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:42: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:44: error: type specifier omitted
   for parameter `SQLCHAR'

C:/Program Files/Dev-Cpp/include/sqlucode.h:44: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:46: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:46: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:48: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:49: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:50: error: type specifier omitted

   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:50: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:51: error: type specifier omitted

   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:51: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:52: error: type specifier omitted

   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:52: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:54: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:54: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:55: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:55: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:58: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:58: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:60: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:60: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:62: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:62: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:64: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:64: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:66: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:66: error: syntax error before `*'

   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:68: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:69: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:70: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:70: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:71: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:71: error: type specifier omitted
   for parameter `SQLUINTEGER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:72: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:72: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:74: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:74: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:74: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:75: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:75: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:75: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:76: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:76: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:77: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:77: error: type specifier omitted
   for parameter `SQLUSMALLINT'
C:/Program Files/Dev-Cpp/include/sqlucode.h:78: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:78: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:80: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:80: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:83: error: `SQLHDESC' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:83: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:83: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:83: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:84: error: `SQLHDESC' was not
   declared in this scope

C:/Program Files/Dev-Cpp/include/sqlucode.h:84: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:84: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:84: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:85: error: `SQLHDESC' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:85: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:85: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:85: error: syntax error before `)'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:85: error: initializer list being
   treated as compound expression
C:/Program Files/Dev-Cpp/include/sqlucode.h:86: error: `SQLHDESC' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:86: error: syntax error before `,'

   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:86: error: `SQLPOINTER' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:86: error: syntax error before `)'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:86: error: initializer list being
   treated as compound expression
C:/Program Files/Dev-Cpp/include/sqlucode.h:87: error: `SQLHDESC' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:87: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:87: error: `SQLCHAR' was not
   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:87: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:88: error: `SQLHDESC' was not

   declared in this scope
C:/Program Files/Dev-Cpp/include/sqlucode.h:88: error: syntax error before `,'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:89: error: type specifier omitted
   for parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sqlucode.h:89: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:90: error: type specifier omitted
   for parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sqlucode.h:90: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:91: error: type specifier omitted

   for parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sqlucode.h:91: error: type specifier omitted
   for parameter `SQLCHAR'
C:/Program Files/Dev-Cpp/include/sqlucode.h:91: error: syntax error before `*'
   token
C:/Program Files/Dev-Cpp/include/sqlucode.h:92: error: type specifier omitted
   for parameter `SQLHANDLE'
C:/Program Files/Dev-Cpp/include/sqlucode.h:93: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:94: error: type specifier omitted
   for parameter `SQLPOINTER'
C:/Program Files/Dev-Cpp/include/sqlucode.h:95: error: type specifier omitted
   for parameter `SQLPOINTER'

C:/Program Files/Dev-Cpp/include/sqlucode.h:96: error: type specifier omitted

   for parameter `SQLPOINTER'
In file included from main.c:1:

odbcutil.H:10: error: `SQLHANDLE' was not declared in this scope
odbcutil.H:10: error: syntax error before `)' token
In file included from getcount.H:3,
                 from main.c:2:
dbstatement.H:12: error: 'SQLHANDLE' is used as a type, but is not defined as a
   type.
dbstatement.H:20: error: `SQLCHAR' was not declared in this scope
dbstatement.H:20: error: `stmt' was not declared in this scope
dbstatement.H:20: error: invalid data member initialization
dbstatement.H:20: error: (use `=' to initialize static data members)
dbstatement.H:20: error: declaration of `SQLRETURN DBstatement::exec'
dbstatement.H:19: error: conflicts with previous declaration `SQLRETURN

   DBstatement::exec()'
dbstatement.H: In member function `SQLRETURN DBstatement::exec()':
dbstatement.H:19: error: `stmthandle' undeclared (first use this function)
dbstatement.H:19: error: (Each undeclared identifier is reported only once for
   each function it appears in.)
main.c: In function `int main(int, char**)':
main.c:25: error: `SQLCHAR' undeclared (first use this function)
main.c:25: error: syntax error before `)' token

make.exe: *** [main.o] Error 1

Execution terminated
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Expert Comment

by:gseidman
ID: 12287801
Yowza! Looks like your ODBC header files are corrupt somehow. The errors seem to be in the sqltypes.h header file, which is a header provided by Microsoft. Try taking a look at that file. All the other errors are a result of missing types which are defined in that header.
0
 

Author Comment

by:Narusegawa
ID: 12287860
Here is a copy of what I got with Dev-C++ (4.9.9.0)

//sqltypes.h

#ifndef _SQLTYPES_H
#define _SQLTYPES_H
#if __GNUC__ >=3
#pragma GCC system_header
#endif

#ifdef __cplusplus
extern "C" {
#endif
#define SQL_API __stdcall
#ifndef RC_INVOKED
#define __need_wchar_t
#include <stddef.h>
typedef signed char SCHAR;
typedef long SDWORD;
typedef short SWORD;
typedef ULONG UDWORD;
typedef USHORT UWORD;
typedef signed long SLONG;
typedef signed short SSHORT;
typedef double SDOUBLE;
typedef double LDOUBLE;
typedef float SFLOAT;
typedef PVOID PTR;
typedef PVOID HENV;
typedef PVOID HDBC;
typedef PVOID HSTMT;
typedef short RETCODE;
typedef UCHAR SQLCHAR;
typedef SCHAR SQLSCHAR;
typedef SDWORD SQLINTEGER;
typedef SWORD SQLSMALLINT;
#ifndef __WIN64
typedef UDWORD SQLUINTEGER;
#endif
typedef UWORD SQLUSMALLINT;
typedef PVOID SQLPOINTER;
#if (ODBCVER >= 0x0300)
typedef void* SQLHANDLE;
typedef SQLHANDLE SQLHENV;
typedef SQLHANDLE SQLHDBC;
typedef SQLHANDLE SQLHSTMT;
typedef SQLHANDLE SQLHDESC;
#else
typedef void* SQLHENV;
typedef void* SQLHDBC;
typedef void* SQLHSTMT;
#endif
typedef SQLSMALLINT SQLRETURN;
typedef HWND SQLHWND;
typedef ULONG BOOKMARK;
#ifdef _WIN64
typedef INT64 SQLLEN;
typedef INT64 SQLROWOFFSET;
typedef UINT64 SQLROWCOUNT;
typedef UINT64 SQLULEN;
typedef UINT64 SQLTRANSID;
typedef unsigned long SQLSETPOSIROW;
#else
#define SQLLEN SQLINTEGER
#define SQLROWOFFSET SQLINTEGER
#define SQLROWCOUNT SQLUINTEGER
#define SQLULEN SQLUINTEGER
#define SQLTRANSID DWORD
#define SQLSETPOSIROW SQLUSMALLINT
#endif
typedef wchar_t SQLWCHAR;
#ifdef UNICODE
typedef SQLWCHAR        SQLTCHAR;
#else
typedef SQLCHAR         SQLTCHAR;
#endif  /* UNICODE */
#if (ODBCVER >= 0x0300)
typedef unsigned char   SQLDATE;
typedef unsigned char   SQLDECIMAL;
typedef double          SQLDOUBLE;
typedef double          SQLFLOAT;
typedef unsigned char   SQLNUMERIC;
typedef float           SQLREAL;
typedef unsigned char   SQLTIME;
typedef unsigned char   SQLTIMESTAMP;
typedef unsigned char   SQLVARCHAR;
#define ODBCINT64      __int64
typedef __int64 SQLBIGINT;
typedef unsigned __int64 SQLUBIGINT;
#endif

typedef struct tagDATE_STRUCT {
      SQLSMALLINT year;
      SQLUSMALLINT month;
      SQLUSMALLINT day;
} DATE_STRUCT;
typedef struct tagTIME_STRUCT {
      SQLUSMALLINT hour;
      SQLUSMALLINT minute;
      SQLUSMALLINT second;
} TIME_STRUCT;
typedef struct tagTIMESTAMP_STRUCT {
      SQLSMALLINT year;
      SQLUSMALLINT month;
      SQLUSMALLINT day;
      SQLUSMALLINT hour;
      SQLUSMALLINT minute;
      SQLUSMALLINT second;
      SQLUINTEGER fraction;
} TIMESTAMP_STRUCT;
#if (ODBCVER >= 0x0300)
typedef DATE_STRUCT      SQL_DATE_STRUCT;
typedef TIME_STRUCT      SQL_TIME_STRUCT;
typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
typedef enum {
      SQL_IS_YEAR = 1,SQL_IS_MONTH,SQL_IS_DAY,SQL_IS_HOUR,
      SQL_IS_MINUTE,SQL_IS_SECOND,SQL_IS_YEAR_TO_MONTH,SQL_IS_DAY_TO_HOUR,
      SQL_IS_DAY_TO_MINUTE,SQL_IS_DAY_TO_SECOND,SQL_IS_HOUR_TO_MINUTE,
      SQL_IS_HOUR_TO_SECOND,SQL_IS_MINUTE_TO_SECOND
} SQLINTERVAL;
typedef struct tagSQL_YEAR_MONTH {
      SQLUINTEGER year;
      SQLUINTEGER month;
} SQL_YEAR_MONTH_STRUCT;
typedef struct tagSQL_DAY_SECOND {
      SQLUINTEGER day;
      SQLUINTEGER      hour;
      SQLUINTEGER minute;
      SQLUINTEGER second;
      SQLUINTEGER fraction;
} SQL_DAY_SECOND_STRUCT;
typedef struct tagSQL_INTERVAL_STRUCT {
      SQLINTERVAL interval_type;
      SQLSMALLINT interval_sign;
      union {
            SQL_YEAR_MONTH_STRUCT year_month;
            SQL_DAY_SECOND_STRUCT day_second;
      } intval;
} SQL_INTERVAL_STRUCT;
#define SQL_MAX_NUMERIC_LEN 16
typedef struct tagSQL_NUMERIC_STRUCT {
      SQLCHAR precision;
      SQLSCHAR scale;
      SQLCHAR sign;
      SQLCHAR val[SQL_MAX_NUMERIC_LEN];
} SQL_NUMERIC_STRUCT;
#endif  /* ODBCVER >= 0x0300 */
#if (ODBCVER >= 0x0350)

#ifdef _GUID_DEFINED
# warning _GUID_DEFINED is deprecated, use GUID_DEFINED instead
#endif

#if defined _GUID_DEFINED || defined GUID_DEFINED
typedef GUID SQLGUID;
#else
typedef struct tagSQLGUID{
    DWORD Data1;
    WORD Data2;
    WORD Data3;
    BYTE Data4[ 8 ];
} SQLGUID;
#endif  /* GUID_DEFINED */
#endif  /* ODBCVER >= 0x0350 */
#endif     /* RC_INVOKED */
#ifdef __cplusplus
}
#endif
#endif
0
 
LVL 1

Expert Comment

by:gseidman
ID: 12288255
Ah! I now see your problem. You are using Dev-C++ header files, but should be using Microsoft's header files. You need to have C:\Program Files\Microsoft Visual Studio\VC98\Include (or something similar) in your include path ahead of Dev-C++ includes so that you are using the right headers. If you do not have Visual Studio then you need to get the freely downloadable compiler (with various headers) from Microsoft at http://msdn.microsoft.com/visualc/vctoolkit2003/

You may find that you are better off using the Microsoft compiler anyway.
0
 

Author Comment

by:Narusegawa
ID: 12288346
I have Visual C++ 6 and 2003.net but I was trying to avoid using it for cross-platform compatibility. I'm gonna try with the MDAC SDK kit which says it has the headers also.
0
 

Author Comment

by:Narusegawa
ID: 12288625
I just loaded up Visual Studio 2003 and started a new Visual C++ project and the SLXTest.cpp (main source file) only has

// This is the main project file for VC++ application project
// generated using an Application Wizard.

#include "stdafx.h"
#include <sql.h>

#using <mscorlib.dll>

using namespace System;

int _tmain()
{
    // TODO: Please replace the sample code below with your own.
    Console::WriteLine(S"Hello World");
      return 0;
}

And this still comes up with syntax errors in sqltypes.h
0
 

Author Comment

by:Narusegawa
ID: 12288665
------ Build started: Project: SQLTest, Configuration: Debug Win32 ------

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

Build log was saved at "file://c:\Documents and Settings\ncg\My Documents\Visual Studio Projects\SQLTest\SQLTest\Debug\BuildLog.htm"
SQLTest - 14 error(s), 0 warning(s)


---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped


0
 
LVL 1

Expert Comment

by:gseidman
ID: 12289374
At this point, I'm baffled. This appears to be a system header problem, and one I've never encountered (I don't really develop on Windows). Best of luck, but I've reached the end of my expertise here. Sorry.
0
 

Author Comment

by:Narusegawa
ID: 12296124
Thanks for all your help anyway. I've gotten a bit further than yesterday. I had to include windows.h as USHORT and ULONG and some other typedef's are defined in that.

Would it help if I upload the project I've got (with your files)? I changed main.c to main.cpp but I don't think that should make a difference.
0
 
LVL 1

Expert Comment

by:gseidman
ID: 12296495
Since I don't have a Windows box to work on, having your project won't help. Changing main.c to main.cpp shouldn't make much difference. (Though it may get the compiler to treat it as C++ rather than C, which is desirable, it doesn't change what's going on with these errors.) Good luck.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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 viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

757 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

21 Experts available now in Live!

Get 1:1 Help Now