Question

Getting "Terrasoft.Common.InvalidObjectStateException: Specify data type for parameter "P1" with null value." error

Since a few days , I get this error : "Terrasoft.Common.InvalidObjectStateException: Specify data type for parameter "P1" with null value." when calling a select command in my script tasks. The way is call them is like this : 

  public Guid Get_bankaccountid(string bankaccount)
 {
     Guid bankaccountid = new Guid();
     string ourBankAccountTable = "UsrOurBankaccount";
     var userconnection = UserConnection.Current;
     var entitySchemaManager = userconnection.EntitySchemaManager;
     var entitySchema_ourbank = entitySchemaManager.GetInstanceByName(ourBankAccountTable);
     var bankrec = new QueryParameter(bankaccount);
     var select_bank = new Select(userconnection)
         .Column("Id")
         .Column("UsrName")
         .Column("UsrActive")
         .From(ourBankAccountTable)
         .Where("UsrName").IsEqual(bankrec)
         as Select;
     using (DBExecutor dbExecutor_bank = userconnection.EnsureDBConnection())
     {
         using (System.Data.IDataReader reader = select_bank.ExecuteReader(dbExecutor_bank))
         {
             if (reader.Read())
             {
                 if ((bool)reader["UsrActive"])
                 {
                     bankaccountid = (Guid)reader["Id"];
                 }
             }
         }

     }
     return bankaccountid;
 }

This code has run for months, and is now causing problems in my clouded deployments. On my local system however, it runs perfectly. Has anyone any idea what has changed?

 

Greetings,

 

Vincent

 

 

 

Like 0

Like

2 comments

Maybe try modifying the Where part of the Select? Try changing from this:

.Where("UsrName").IsEqual(bankrec)

To this: 

.Where("UsrName").IsEqual(Column.Const(bankaccount))

Not sure if this is the issue, but worth trying.

Ryan

Hello,
Ryan is right, you are passing the parameter to Where condition incorrectly, please take a look at this article where you can find examples on how to do so.

Show all comments