?
Solved

dbbind error

Posted on 2004-10-09
1
Medium Priority
?
439 Views
Last Modified: 2007-12-19
I get the below error on dbbind when attempting to build the below module.  What could be causing this?

error:
Performing Custom Build Step on .\test.sc
ESQL test.sc:
Compiling...
test.cpp
c:\test\test.cpp(25) : error C2664: 'dbbind' : cannot convert parameter 5 from 'char *' to 'unsigned char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

test.sc:
#define      DBNTWIN32
#include "windows.h"
#include <sqlfront.h>
#include <sqldb.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <time.h>

PDBPROCESS dbproc;
PLOGINREC login;
RETCODE result_code;

char sql_stmt[256];
char testvar[51];

void main() {
  void sqlconn();

  sqlconn();

  sprintf(sql_stmt,"SELECT testvar FROM testtable");
  dbcmd(dbproc,sql_stmt);
  dbsqlexec(dbproc);

  while ((result_code = dbresults(dbproc)) != NO_MORE_RESULTS) {
    if (result_code == SUCCEED) {
        dbbind (dbproc,1,NTBSTRINGBIND,(DBINT) 0,(char *) testvar);

        while (dbnextrow(dbproc) != NO_MORE_ROWS) {
          fprintf(stdout,"testvar: %s\n",testvar);
        }
      }
  }
}

/* sqlconn procedure */

void sqlconn() {
  if (dbinit() == (char *)NULL) {
      fprintf(stdout,"Communications layer not loaded!\n");
      return;
  }

  login = dblogin();
  DBSETLUSER(login,(char *)"testlogin");
  DBSETLAPP(login,(char *)"testapp");
  DBSETLPWD(login,(char *)"testpwd");
  DBSETLVERSION(login,DBVER60);

  if ((dbproc = dbopen(login,"testsvr")) == NULL) {
      fprintf(stdout,"dbopen failed!\n");
      return;
  }

  dbuse(dbproc,"testdb");
  fprintf(stdout,"Success!\n");

} /* end sqlconn procedure */
0
Comment
Question by:arichexe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 15

Accepted Solution

by:
efn earned 500 total points
ID: 12269196
The fifth parameter to dbbind is declared as LPBYTE.  (I assume you are using the dbbind from the Microsoft SQL Server DB-Library.)  LPBYTE is a pointer to a BYTE.  A BYTE is an unsigned char.  So the parameter type is unsigned char*.  You are passing a pointer to char, not unsigned char, as this parameter, and that's not close enough for the compiler.  The simplest fix would be to declare the testvar array as an array of unsigned char.  Then you could just use its name as the parameter, without a cast, and the compiler would be satisfied.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.
Suggested Courses

800 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