Skip to Content.
Sympa Menu

freetds - Re: [freetds] dblib program

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] dblib program
  • Date: Mon, 4 Aug 2003 19:03:00 -0400

On Mon, 4 Aug 2003 11:28:34 -0600 (MDT), "Steven J. Backus"
<backus AT math.utah.edu> wrote:
> I have reduced my dblib problem considerably and even have a
> workaround, so if you can't replicate it, or fix it, I'm ok. Still, I
> would like to make freetds better, so I'm sending this off with
> great hope.

Thanks for boiling it down, Steven. It may be there's a problem with
DBCHAR binding. It deserves scrutiny; there are many opportunities in
that code for off-by-one errors.
--jkl

>
> First the table def:
>
> create table table1
> (i1 varchar(4) null,
> family varchar(1) null)
> go
>
> Then the insert statement:
>
> insert into table1(i1, family) values ('I64', 'Y');
>
> Now the program:
>
> main(int argc, char** argv) {
> DBPROCESS *dbproc;
> LOGINREC *login;
> DBCHAR i1[5], family;
>
> ...
>
> dbcmd(dbproc, "select i1, family from table1 ");
> dbsqlexec(dbproc);
> if(dbresults(dbproc) == SUCCEED) {
> dbbind(dbproc, 1, STRINGBIND, (DBINT)0, (BYTE*) i1);
> dbbind(dbproc, 2, CHARBIND, (DBINT)0, (BYTE*) &family);
>
> dbnextrow(dbproc);
> printf("%s\n", i1);
> }
> }
>
> In its present state, the program prints nothing. However, if I
> change family to a string:
>
> DBCHAR i1[5], family[2];
>
> and bind it thus:
>
> dbbind(dbproc, 2, STRINGBIND, (DBINT)0, (BYTE*) family);
>
> The printf works and spits out I64. Thank you one and all for your
> time and consideration. Let me know if I can provide further
> clues.
>
> Steven
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds




Archive powered by MHonArc 2.6.24.

Top of Page