08-08-2016 06:22 AM
Hi, i manage to connect to ACT database using an odbc connection with sql server driver.
However, whenever i try to execute a query, i get this error:
Warning: odbc_exec(): SQL error: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Conversion failed when converting from a character string to uniqueidentifier., SQL state 37000 in SQLExecDirect in C:\wamp64\www\Act\act.php on line 40.
i use this code:
$dsn="Driver={ODBC Driver 11 for SQL Server};Server={178.xxx.x.xx,port};Database=TESTJR;";
$user="ACTREADER";
$mdp="Incisiv357";
$connection=odbc_connect($dsn, $user, $mdp);
if($connection==false)
print_r(odbc_error($connection));
else{
echo "Connection réussie";
try{
$requete="select contact from CONTACT";
odbc_exec($connection, $requete);
}
catch(exception $e){
print_r($e);
}
}
Is it possible that i'm using the wrong driver? although i've tried a couple.
Any help would be appreciated.
I'm using ACT Premium version 18 and i have ACTREADER set up properly.
08-09-2016 03:54 AM
Actually, i solved my problem.The table contact can't be accessed through odbc, i have to use TBL_CONTACT and is working just fine. The only problem is my customed fields don't have the same name as in act!
08-08-2016 12:52 PM
Based on the message you posted
Conversion failed when converting from a character string to uniqueidentifier
It looks to be more of a query issue than a driver issue. At the very least, proving out the query is a lot easier than the driver. Is the SQL query that you posted one that you've tried out? The query you posted shouldn't be doing anything with uniqueidentifier, so I would presume that the posted query isn't what you are actually trying. If it is, you shouldn't be getting a SQL error about converting character data to a uniqueidentifier.
Could you please post the actual SQL statement you are running or post the results of the statement you posted: "Select contact From CONTACT"?
08-08-2016 11:44 PM
08-09-2016 01:17 AM
Thanks for your interest and quick replies. I agree with you that i shoundn't get this error since i'm not using the contactid column in my query.
But i can assure you that's the query that generate the error. Actually any query reproduce the same error. That's why i think it's maybe the driver version but at the same time the connection to the database works just fine.
should i use table like TBL_CONTACT for ODBC?
line 40 is dbc_exec($connection, $requete);
08-09-2016 01:18 AM
line 40 : odbc_exec($connection, $requete);
08-09-2016 03:54 AM
Actually, i solved my problem.The table contact can't be accessed through odbc, i have to use TBL_CONTACT and is working just fine. The only problem is my customed fields don't have the same name as in act!