Solved

dbbind error

Posted on 2004-10-09
1
426 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
1 Comment
 
LVL 15

Accepted Solution

by:
efn earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

867 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

19 Experts available now in Live!

Get 1:1 Help Now