1. Fabio Pontel
  2. PowerBuilder
  3. Monday, 9 October 2023 11:14 AM UTC
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
//////////////////////////////////////////////////
Fabio Pontel Accepted Answer Pending Moderation
  1. Tuesday, 10 October 2023 15:01 PM UTC
  2. PowerBuilder
  3. # 1

I couldn't debug it the way I needed to. But I fixed the false return from the setadoconnection() function.

I just added this line before the setadoconnection call:


SQLCA.DBMS = "ADO.Net"

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.