Odbc error on Linux

Post Reply
User avatar
Massimo Linossi
Posts: 508
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Odbc error on Linux

Post 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
User avatar
karinha
Posts: 7940
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

Re: Odbc error on Linux

Post by karinha »

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
Massimo Linossi
Posts: 508
Joined: Mon Oct 17, 2005 10:38 am
Location: Italy

Re: Odbc error on Linux

Post 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
Post Reply