SQLINTEGER 的 ODBC 错误

发布于 2024-10-03 09:06:24 字数 870 浏览 1 评论 0原文

这个错误是什么意思我已经尝试了所有可能的改变它的方法,但它不起作用。

无法将参数 '6' 的 'SQLINTEGER*' 转换为 'long int*' 到 'SQLRETURN SQLGetData(void*, SQLUSMALLINT, SQLSMALLINT, void*, long int, long int*)' 强调文本

Here is the code
#ifndef CPSC_408_DB_H
#define CPSC_408_DB_H

#include <sql.h>
#include <sqlext.h>
#include <iostream>
#include <string> using namespace std;


class Monster {   public:

  Monster(string dsn);   ~Monster();
     void execQuery();


  private:   //used for connection and status   
   SQLHENV env;  
   SQLHDBC dbc;   
   SQLHSTMT stmt;   
   SQLRETURN ret; /* ODBC API return status */   
   SQLCHAR outstr[1024];   SQLSMALLINT outstrlen;




};



#endif


//sql getdata method
/* retrieve column data as a string */
  ret = SQLGetData(stmt, i+1, SQL_C_CHAR,
                         buf, sizeof(buf), &indicator);

What does this error mean I have tried All possible means of changing it but it is not working.

cannot convert ‘SQLINTEGER*’ to ‘long int*’ for argument ‘6’ to ‘SQLRETURN SQLGetData(void*, SQLUSMALLINT, SQLSMALLINT, void*, long int, long int*)’emphasized text

Here is the code
#ifndef CPSC_408_DB_H
#define CPSC_408_DB_H

#include <sql.h>
#include <sqlext.h>
#include <iostream>
#include <string> using namespace std;


class Monster {   public:

  Monster(string dsn);   ~Monster();
     void execQuery();


  private:   //used for connection and status   
   SQLHENV env;  
   SQLHDBC dbc;   
   SQLHSTMT stmt;   
   SQLRETURN ret; /* ODBC API return status */   
   SQLCHAR outstr[1024];   SQLSMALLINT outstrlen;




};



#endif


//sql getdata method
/* retrieve column data as a string */
  ret = SQLGetData(stmt, i+1, SQL_C_CHAR,
                         buf, sizeof(buf), &indicator);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鹿港巷口少年归 2024-10-10 09:06:24

如果您将编译器抱怨的 SQLGetData 的实际调用以及所有相关声明发布出来,将会有所帮助,但我会尝试一下。

SQLGetData 的最后一个参数应该是指向 long int 的指针(有时在某些版本的 ODBC 文档中称为 SDWORD),而不是指向 SQLINTEGER 的指针。检查您要传递地址的变量的类型,并根据需要更新它。

分享并享受。

It would help if you'd post the actual call to SQLGetData that the compiler is griping about, along with all related declarations, but I'll take a stab at it.

The last parameter to SQLGetData is supposed to a pointer to a long int (sometimes referred to as an SDWORD in some versions of the ODBC docs), not a pointer to an SQLINTEGER. Check the type of the variable whose address you're passing and update it as necessary.

Share and enjoy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文