Solved

dbbind error

Posted on 2004-10-09
1
432 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 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

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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.

749 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