Page 1 of 1

Odbc error on Linux

Posted: Fri Feb 14, 2025 3:47 pm
by Massimo Linossi
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.

Code: Select all | Expand

#!/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

Code: Select all | Expand

#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

Re: Odbc error on Linux

Posted: Fri Feb 14, 2025 4:06 pm
by karinha

Re: Odbc error on Linux

Posted: Fri Feb 14, 2025 7:09 pm
by Massimo Linossi
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