freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Kenny Pang <eekhpang AT ee.ust.hk>
- To: freetds AT franklin.oit.unc.edu
- Subject: dblib sample program does not run
- Date: Wed, 1 Sep 1999 18:43:29 +0800
Hi
I am new to FreeTDS. I successfully compiled and installed freetds 0.46
in Redhat Linux 6.0. It was configured with "--with-tdsver=4.2".
However when I try some very sample programs to retrieve rows from a MS
SQL server, the results are not the one I expected. The sample program
is extracted from the MS SQL server 7.0 online book. It caused
segmentation fault in the line
while (dbnextrow(dbproc) != NO_MORE_ROWS)
When total while block is commented, it runs but the printf outputs some
rubbish, instead of the correct column.
The sample program and the compile option is attached. Can somebody tell
me what stupid mistake I have made or anything I have missed. Thanks a
lot...
cc -o sample.c sample.c -I/usr/local/freetds/include
-L/usr/local/freetds/lib -lsybdb -lnsl
------------------------------------------------------------------
sample.c
------------------------------------------------------------------
#include <stdio.h>
#include <sqlfront.h>
#include <sqldb.h>
main()
{
DBPROCESS *dbproc; // The connection with SQL Server.
LOGINREC *login; // The login information.
DBCHAR name[100];
DBCHAR city[100];
// Install user-supplied error- and message-handling functions.
dbinit ();
// Get a LOGINREC.
login = dblogin();
DBSETLUSER(login, "sa");
DBSETLPWD(login, "");
DBSETLAPP(login, "example");
// Get a DBPROCESS structure for communication with SQL Server.
dbproc = dbopen(login, "eex861");
// Retrieve some columns from the authors table in the // pubs
database.
// First, put the command into the command buffer.
dbcmd(dbproc, "SELECT au_lname, city FROM pubs..authors");
dbcmd(dbproc, " WHERE state = 'CA' ");
// Send the command to SQL Server and start execution.
dbsqlexec(dbproc);
// Process the results.
if (dbresults(dbproc) == SUCCEED)
{
// Bind column to program variables.
dbbind(dbproc, 1, NTBSTRINGBIND, 0, name);
dbbind(dbproc, 2, NTBSTRINGBIND, 0, city);
// Retrieve and print the result rows.
while (dbnextrow(dbproc) != NO_MORE_ROWS)
{
printf("%s from %s\n", name, city);
}
}
// Close the connection to SQL Server.
dbexit();
return(0);
-
dblib sample program does not run,
Kenny Pang, 09/01/1999
- <Possible follow-up(s)>
- Re: dblib sample program does not run, Brian Bruns, 09/01/1999
- Re: dblib sample program does not run, Brian Bruns, 09/01/1999
- Re: dblib sample program does not run, Kenny Pang, 09/02/1999
- Re: dblib sample program does not run, Brian Bruns, 09/02/1999
Archive powered by MHonArc 2.6.24.