FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Odbc error on Linux
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Odbc error on Linux
Posted: Fri Feb 14, 2025 03:47 PM
Hi to all.
I wish to ask you a suggestion to find the I am making an error.
This bash on a Linux machine works perfectly. Using a command-line utility from MS I can extract some records from another server with SQL-Server.
#!/bin/bash
cUser='admin'
cPass='Max61'
cServer='125.15.13.12'
cQuery="SELECT ut codice_cliente, rag nominativo, cf codice_fiscale, piv partita_iva FROM ute WHERE rag like '%MAX%'"
/opt/mssql-tools18/bin/sqlcmd -S $cServer -U $cUser -P $cPass -d BEG_DATI -p -Q "$cQuery" -C
exit 0
This code made on harbour on the same machine gives ERROR BASE/0 Parameter error: SQLCONNECT
#require "hbodbc"
***********************************
Function Main()

LOCAL cConnString, hDbc, hStmt, cQuery, cResult, nFetch 

REQUEST HB_LANG_IT
HB_LANGSELECT("IT")
REQUEST DBFCDX
REQUEST DBFFPT
RddRegister( "DBFCDX", 1 )
RddSetDefault("DBFCDX")
SET(_SET_AUTORDER,1)
SET AUTOPEN ON

SET DATE BRITISH
SET DELETED ON
SET CENTURY ON
SET EPOCH TO YEAR(DATE())

// Define the ODBC connection string (replace with your actual details)
cConnString := "Driver={ODBC Driver 18 for SQL Server};Server=125.15.13.12;Database=SQL_DATI;UID=admin;PWD=Max61;"

// Initialize the connection handle (hDbc) using SQLConnect
hDbc := SQLConnect( cConnString )

// Check if the connection was successful

IF hDbc == NIL
    ? "Connection failed!"
    RETURN
ENDIF
   
Return nil
Thanks a lot for your attention.
Massimo
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Odbc error on Linux
Posted: Fri Feb 14, 2025 04:06 PM
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 512
Joined: Mon Oct 17, 2005 10:38 AM
Re: Odbc error on Linux
Posted: Fri Feb 14, 2025 07:09 PM

Thanks.

But the problem is that I don't understand where is the error in the ODBC connection string for SQL-SERVER.

Using the MS connection utility works perfectly so the ODBC is correct.

Massimo

Posts: 990
Joined: Wed Oct 19, 2005 02:17 PM
Re: Odbc error on Linux
Posted: Sat Feb 22, 2025 01:51 PM
Hi Massimo !!!

From your bash code
/opt/mssql-tools18/bin/sqlcmd -S $cServer -U $cUser -P $cPass -d BEG_DATI -p -Q "$cQuery" -C
and harbour code
cConnString := "Driver={ODBC Driver 18 for SQL Server};Server=125.15.13.12;Database=SQL_DATI;UID=admin;PWD=Max61;"
In bash code database is BEG_DATI and in harbour code is SQL_DATI. Perhaps, this will be the problem.

Best regards,

Continue the discussion