How to debug when SetAdoConnection() returns:False ?
Always returns False .
//////////////////////////////////////////////////
// My code in Pb2022 R2:
//////////////////////////////////////////////////
oleobject leon_sql
boolean lbn_result
string ls_sql
dotnetobject lcs_obj
dotnetassembly lcs_ass
long ll_return,ll_count, ll_result
lcs_obj = create dotnetobject
lcs_ass = create dotnetassembly
//Loads DLL
ll_return = lcs_ass.LoadWithDotNet("C:\Codes\PoderAdoDb.dll")
if ll_return < 0 then
messagebox("Fail - Open PoderAdoDb.dll",lcs_ass.errortext)
return
end if
ll_return = lcs_ass.createinstance("PoderAdoDb.PoderDbConnect",lcs_obj)
if ll_return < 0 then
messagebox("createinstance failed",lcs_ass.errortext)
return
end if
boolean retVal
retVal = SQLCA.SetAdoConnection(lcs_obj.odbcSql) // <- It always returns FALSE at this point!
if retVal then
connect using SQLCA;
if sqlca.sqlcode <> 0 then
messagebox("Error",sqlca.sqlerrtext)
else
//Use the C# connection to execute SQL in PB
select count(*) into :ll_result from dba.empresa;
messagebox("Result",ll_result)
end if
else
messagebox("","Fail - SetAdoConnection") // <- It always returns FALSE at this point!
end if
//////////////////////////////////////////////////
// End - Code Pb2022 - r2
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// My code in C#- SnapDevelop:
//////////////////////////////////////////////////
using Appeon.DB.Sharing;
using System.Data.Odbc;
namespace PoderAdoDb
{
public class PoderDbConnect
{
public IAdoConnectionProxy odbcSql { get; set; }
//Construct a method to send database information to odbcSql
public PoderDbConnect()
{
string connection = "";
connection = "Dsn=OFF17";
OdbcConnection sqlcon = new OdbcConnection(connection);
sqlcon.Open();
IAdoConnectionProxy adosql = new AdoConnectionProxy();
adosql.Connection = sqlcon;
odbcSql = adosql;
}
}
}
//////////////////////////////////////////////////
// End code in C#- SnapDevelop
//////////////////////////////////////////////////