I am trying to access a database hosted on a Microsoft SQL Server 2005 using FreeTDS and iodbc from OpenBSD 4.5 -stable (also tried OpenBSD -current as of today). Unfortunately none of the documents I have read so far or the various trials/tests have helped. I can use tsql and access the SQL Server but I am not able to use iodbcadm-gtk to add a DSN etc.

The standard package as well as the msdblib flavor did not work for me and as a result I made a few changes to the Makefile

Looks like I made some small progress however, I get the error

HYC00 [FreeTDS][SQL Server]Driver not capable
08001: [FreeTDS][SQL Server]Unable to connect to data source

$ cat /usr/ports/databases/freetds/Makefile

# $OpenBSD: Makefile,v 1.30 2007/09/15 20:34:00 simon Exp $

V=              0.63
DISTNAME=       freetds-$V
PKGNAME=        ${DISTNAME}p1
CATEGORIES=     databases
SHARED_LIBS +=  tds                  4.0      # .4.0
SHARED_LIBS +=  ct                   3.0      # .3.0
SHARED_LIBS +=  sybdb                5.0      # .5.0
SHARED_LIBS +=  tdssrv               2.0      # .2.0
SHARED_LIBS +=  tdsodbc              0.0      # added this line here

# GPL
PERMIT_PACKAGE_CDROM=   Yes
PERMIT_PACKAGE_FTP=     Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP=   Yes

WANTLIB=        c ncurses readline

COMMENT=        project to document and implement the TDS protocol
HOMEPAGE=       http://www.freetds.org/
MASTER_SITES=   ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/
~ $ cat /usr/ports/databases/freetds/Makefile
# $OpenBSD: Makefile,v 1.30 2007/09/15 20:34:00 simon Exp $

V=              0.63
DISTNAME=       freetds-$V
PKGNAME=        ${DISTNAME}p1
CATEGORIES=     databases
SHARED_LIBS +=  tds                  4.0      # .4.0
SHARED_LIBS +=  ct                   3.0      # .3.0
SHARED_LIBS +=  sybdb                5.0      # .5.0
SHARED_LIBS +=  tdssrv               2.0      # .2.0
SHARED_LIBS +=  tdsodbc              0.0      # added this lib

# GPL
PERMIT_PACKAGE_CDROM=   Yes
PERMIT_PACKAGE_FTP=     Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP=   Yes

WANTLIB=        c ncurses readline

COMMENT=        project to document and implement the TDS protocol
HOMEPAGE=       http://www.freetds.org/
MASTER_SITES=   ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/

FLAVORS=        msdblib
FLAVOR?=

USE_LIBTOOL=    Yes

CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= ${CONFIGURE_SHARED} \
               --enable-static \
               --with-libiconv-prefix="${LOCALBASE}" \
               --disable-threadsafe \
               --with-iodbc      # Added iodbc

.if $(FLAVOR:L:Mmsdblib)
CONFIGURE_ARGS+=--enable-msdblib
.endif

MAKE_ENV=       RM=rm
MODULES=        converters/libiconv
DOC=            share/doc/freetds-$V
SUBST_VARS=     DOC V

post-install:
       @sed -e "s:@sysconfdir@:${SYSCONFDIR}:g" ${WRKSRC}/freetds.conf > \
               ${WRKSRC}/freetds.conf.new
       @mkdir ${PREFIX}/share/examples/freetds
       ${INSTALL_DATA} ${WRKSRC}/freetds.conf.new \
               ${PREFIX}/share/examples/freetds/freetds.conf-sample
       ${INSTALL_DATA} ${WRKSRC}/src/pool/pool.conf \
               ${PREFIX}/share/examples/freetds/pool.conf-sample
@cd ${PREFIX}/lib && ln -s libtdsodbc.so.${LIBtdsodbc_VERSION} libtdsodbc.so

.include <bsd.port.mk>


The Trace option gives me

~ $ cat /tmp/sql.log
** iODBC Trace file
** Trace started on Tue Jul 14 17:56:36 2009
** Driver Manager: 03.52.0406.0126


[000000.000289]
Application     7FB05400 ENTER SQLAllocHandle
               SQLSMALLINT       1 (SQL_HANDLE_ENV)
               SQLHANDLE         0x0 (SQL_NULL_HANDLE)
               SQLHANDLE       * 0xcfbc9268

[000000.000320]
Application 7FB05400 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
               SQLSMALLINT       1 (SQL_HANDLE_ENV)
               SQLHANDLE         0x0 (SQL_NULL_HANDLE)
               SQLHANDLE       * 0xcfbc9268 (0x853cfb20)

[000000.000343]
Application     7FB05400 ENTER SQLSetEnvAttr
               SQLHENV           0x853cfb20
               SQLINTEGER        200 (SQL_ATTR_ODBC_VERSION)
               SQLPOINTER        0x3
               SQLINTEGER      * -5 (SQL_IS_UINTEGER)

[000000.000374]
Application 7FB05400 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
               SQLHENV           0x853cfb20
               SQLINTEGER        200 (SQL_ATTR_ODBC_VERSION)
               SQLPOINTER        0x3
               SQLINTEGER      * -5 (SQL_IS_UINTEGER)

[000000.000392]
Application     7FB05400 ENTER SQLAllocHandle
               SQLSMALLINT       2 (SQL_HANDLE_DBC)
               SQLHANDLE         0x853cfb20
               SQLHANDLE       * 0xcfbc9264

[000000.000413]
Application 7FB05400 EXIT SQLAllocHandle with return code 0 (SQL_SUCCESS)
               SQLSMALLINT       2 (SQL_HANDLE_DBC)
               SQLHANDLE         0x853cfb20
               SQLHANDLE       * 0xcfbc9264 (0x8abb2d00)

[000000.000443]
Application     7FB05400 ENTER SQLDriverConnect
               SQLHDBC           0x8abb2d00
               SQLPOINTER        0x80c64000
               SQLCHAR         * 0xcfbca270
| DSN=pmnew |
               SQLSMALLINT       -3 (SQL_NTS)
               SQLCHAR         * 0xcfbc9270
               SQLSMALLINT       4096
               SQLSMALLINT     * 0xcfbc9262
               SQLUSMALLINT      2 (SQL_DRIVER_PROMPT)

[000006.506389]
Application 7FB05400 EXIT SQLDriverConnect with return code -1 (SQL_ERROR)
               SQLHDBC           0x8abb2d00
               SQLPOINTER        0x80c64000
               SQLCHAR         * 0xcfbca270
               SQLSMALLINT       -3 (SQL_NTS)
               SQLCHAR         * 0xcfbc9270
               SQLSMALLINT       4096
               SQLSMALLINT     * 0xcfbc9262
               SQLUSMALLINT      2 (SQL_DRIVER_PROMPT)

[000006.506502]
Application     7FB05400 ENTER SQLError
               SQLHENV           0x853cfb20
               SQLHDBC           0x8abb2d00
               SQLHSTMT          0x0 (SQL_NULL_HANDLE)
               SQLCHAR         * 0xcfbc9100
               SQLINTEGER      * 0x0
               SQLCHAR         * 0xcfbc9110
               SQLINTEGER        250
               SQLSMALLINT     * 0x0

[000006.506655]
Application     7FB05400 EXIT  SQLError with return code 0 (SQL_SUCCESS)
               SQLHENV           0x853cfb20
               SQLHDBC           0x8abb2d00
               SQLHSTMT          0x0 (SQL_NULL_HANDLE)
               SQLCHAR         * 0xcfbc9100
| HYC00 |
               SQLINTEGER      * 0x0
               SQLCHAR         * 0xcfbc9110
| [FreeTDS][SQL Server]Driver not capable |
               SQLINTEGER        250
               SQLSMALLINT     * 0x0

[000044.342636]
Application     7FB05400 ENTER SQLError
               SQLHENV           0x853cfb20
               SQLHDBC           0x8abb2d00
               SQLHSTMT          0x0 (SQL_NULL_HANDLE)
               SQLCHAR         * 0xcfbc9100
               SQLINTEGER      * 0x0
               SQLCHAR         * 0xcfbc9110
               SQLINTEGER        250
               SQLSMALLINT     * 0x0

[000044.342690]
Application     7FB05400 EXIT  SQLError with return code 0 (SQL_SUCCESS)
               SQLHENV           0x853cfb20
               SQLHDBC           0x8abb2d00
               SQLHSTMT          0x0 (SQL_NULL_HANDLE)
               SQLCHAR         * 0xcfbc9100
| 08001 |
               SQLINTEGER      * 0x0
               SQLCHAR         * 0xcfbc9110
| [FreeTDS][SQL Server]Unable to connect t | | o data source |
               SQLINTEGER        250
               SQLSMALLINT     * 0x0

[000067.341588]
Application     7FB05400 ENTER SQLError
               SQLHENV           0x853cfb20
               SQLHDBC           0x0 (SQL_NULL_HANDLE)
               SQLHSTMT          0x0 (SQL_NULL_HANDLE)
               SQLCHAR         * 0xcfbc9100
               SQLINTEGER      * 0x0
               SQLCHAR         * 0xcfbc9110
               SQLINTEGER        250
               SQLSMALLINT     * 0x0

[000067.341634]
Application 7FB05400 EXIT SQLError with return code 100 (SQL_NO_DATA_FOUND)
               SQLHENV           0x853cfb20
               SQLHDBC           0x0 (SQL_NULL_HANDLE)
               SQLHSTMT          0x0 (SQL_NULL_HANDLE)
               SQLCHAR         * 0xcfbc9100
               SQLINTEGER      * 0x0
               SQLCHAR         * 0xcfbc9110
               SQLINTEGER        250
               SQLSMALLINT     * 0x0

[000067.341704]
Application     7FB05400 ENTER SQLFreeHandle
               SQLSMALLINT       2 (SQL_HANDLE_DBC)
               SQLHDBC           0x8abb2d00

[000067.341748]
Application 7FB05400 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
               SQLSMALLINT       2 (SQL_HANDLE_DBC)
               SQLHDBC           0x8abb2d00

[000067.341763]
Application     7FB05400 ENTER SQLFreeHandle
               SQLSMALLINT       1 (SQL_HANDLE_ENV)
               SQLHENV           0x853cfb20

[000067.341780]
Application 7FB05400 EXIT SQLFreeHandle with return code 0 (SQL_SUCCESS)
               SQLSMALLINT       1 (SQL_HANDLE_ENV)
               SQLHENV           0x853cfb20

** Trace finished on Tue Jul 14 17:57:43 2009

I hope the list can give me any advice or pointers on what is the best way to access data from a SQL Server 2005 database from OpenBSD

Thanks very much,

Vijay

--
Vijay Sankar, M.Eng., P.Eng.
ForeTell Technologies Limited
59 Flamingo Avenue, Winnipeg, MB, Canada R3J 0X6
Phone: (204) 885-9535, E-Mail: vsan...@foretell.ca

Reply via email to