_neto_ 0 Denunciar post Postado Abril 30, 2008 Pessoal, estou tentando rodar o seguinte código, pra conexão com banco de dados via ODBC: #include <cstdlib> #include <iostream> #include <sql.h> #include <sqlext.h> using namespace std; int main(int argc, char *argv[]) { //Declaration: SQLHandle hdlEnv, hdlConn, hdlStmt, hdlDbc char* stmt = "SELECT * from tab1"; //SQL statement? NutHead is the Table name //for example char *dsnName = "dbteste" // name of your program or what ever….. char* userID = ""; char* passwd = ""; char* retVal[256]; unsigned int cbData; SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hdlEnv); SQLSetEnvAttr(hdlEnv,SQL_ATTR_ODBC_VERSION,(void*)SQL_OV_ODBC30); SQLAllocHandle(SQL_HANDLE_DBC, hdlEnv, &hdlConn); SQLConnect(hdlConn, (SQLCHAR*)dsnName,SQL_NTS,(SQLCHAR*)userID,SQL_NTS, (SQLCHAR*)passwd, SQL_NTS); SQLAllocHandle(SQL_HANDLE_STMT, hdlDbc, &hdlStmt); SQLExecDirect(hdlStmt, (SQLCHAR*)stmt, SQL_NTS); //Initialize the database connection while(SQLFetch(hdlStmt) == SQL_SUCCEEDED) { SQLGetData(hdlStmt,0,DT_STRING,retVal,256,&cbData); std::cout << retVal << std::endl; } SQLFreeHandle(SQL_HANDLE_STMT, hdlStmt); SQLFreeHandle(SQL_HANDLE_DBC, hdlConn); SQLFreeHandle(SQL_HANDLE_ENV, hdlEnv); //End the connection return EXIT_SUCCESS; } mas aparecem as mensagens de erro: In file included from C:/Dev-Cpp/include/sql.h:13, from main.cpp:3: C:/Dev-Cpp/include/sqltypes.h:17: error: `ULONG' does not name a type C:/Dev-Cpp/include/sqltypes.h:18: error: `USHORT' does not name a type C:/Dev-Cpp/include/sqltypes.h:24: error: `PVOID' does not name a type C:/Dev-Cpp/include/sqltypes.h:25: error: `PVOID' does not name a type C:/Dev-Cpp/include/sqltypes.h:26: error: `PVOID' does not name a type C:/Dev-Cpp/include/sqltypes.h:27: error: `PVOID' does not name a type C:/Dev-Cpp/include/sqltypes.h:29: error: `UCHAR' does not name a type C:/Dev-Cpp/include/sqltypes.h:34: error: `UDWORD' does not name a type C:/Dev-Cpp/include/sqltypes.h:36: error: `UWORD' does not name a type C:/Dev-Cpp/include/sqltypes.h:37: error: `PVOID' does not name a type C:/Dev-Cpp/include/sqltypes.h:50: error: `HWND' does not name a type C:/Dev-Cpp/include/sqltypes.h:51: error: `ULONG' does not name a type C:/Dev-Cpp/include/sqltypes.h:71: error: `SQLCHAR' does not name a type C:/Dev-Cpp/include/sqltypes.h:90: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:91: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:94: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:95: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:96: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:100: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:101: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:102: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:103: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:104: error: `SQLUSMALLINT' does not name a type C:/Dev-Cpp/include/sqltypes.h:105: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:118: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:119: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:122: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:123: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:124: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:125: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:126: error: `SQLUINTEGER' does not name a type C:/Dev-Cpp/include/sqltypes.h:138: error: `SQLCHAR' does not name a type C:/Dev-Cpp/include/sqltypes.h:140: error: `SQLCHAR' does not name a type C:/Dev-Cpp/include/sqltypes.h:141: error: `SQLCHAR' does not name a type C:/Dev-Cpp/include/sqltypes.h:154: error: `DWORD' does not name a type C:/Dev-Cpp/include/sqltypes.h:155: error: `WORD' does not name a type C:/Dev-Cpp/include/sqltypes.h:156: error: `WORD' does not name a type C:/Dev-Cpp/include/sqltypes.h:157: error: `BYTE' does not name a type Qual o problema que está havendo? Eu já linkei a biblioteca do odbc no projeto, é necessário mais alguma outra? Obrigado a quem ajudar. Compartilhar este post Link para o post Compartilhar em outros sites
quitZAUMMM 18 Denunciar post Postado Abril 30, 2008 será q ñ falta nenhuma biblioteca? pq oq eu acho é q esta dando esse erro pq ele naum esta encontrando esses tipos! Compartilhar este post Link para o post Compartilhar em outros sites
_neto_ 0 Denunciar post Postado Abril 30, 2008 também percebi isso, mas qual biblioteca? eu nunca vi esses tipos, e esse arquivo sqltypes.h está na biblioteca do odbc. Compartilhar este post Link para o post Compartilhar em outros sites
_neto_ 0 Denunciar post Postado Abril 30, 2008 Consegui achar o problema. Era necessário adicionar as bibliotecas do windows (windows.h). Compartilhar este post Link para o post Compartilhar em outros sites
quitZAUMMM 18 Denunciar post Postado Abril 30, 2008 q bom q resolveu! http://forum.imasters.com.br/public/style_emoticons/default/thumbsup.gif Compartilhar este post Link para o post Compartilhar em outros sites
Robex 171 0 Denunciar post Postado Maio 21, 2008 Qual o nome da biblioteca do ODBC qque você linkou? Essa solução exige que seja criado uma instancia no ODBC? Aguardo resposta, urgência! Grato desde já! Compartilhar este post Link para o post Compartilhar em outros sites