1. Haakon Langballe
  2. PowerBuilder
  3. Tuesday, 10 December 2019 08:51 AM UTC

Hi.

My application has started pop up a message box on some data fetches.

The message is "Select error: SQL State = 22005 ... Invalid character for cast specification"

This may have started when I changed the connection to a newer SQL server. The provider is MS Native client 11.

I tried to set parameters on the transaction object without success. The exception handler is not catching this, I guess it is already handled.

This is my code fragment. The parameters to Retrieve() is matching the table column types.

Any ideas?

sqlca.DBParm="StripParamNames='Yes'"
sqlca.DBParm="CallEscape='No'"
dw_picker.settransobject(sqlca)
TRY
  dw_picker.retrieve(1, 'B')
CATCH(Exception ex)
  MessageBox("Error", ex.GetMessage())
END TRY

Michael Kramer Accepted Answer Pending Moderation
  1. Tuesday, 10 December 2019 11:02 AM UTC
  2. PowerBuilder
  3. # 1

Hi Haakon, this is my initial gut feeling knowing no code, nor data in your app >>>

Are you using DisableBind=1 to enable SQL Injection attacks?

Invalid cast is most probably a numeric, date, time, or datetime value acting "weird" since Unicode means any text character should be good to go.

Now, numeric in case decimal separator is misunderstood seldom but it may happen. Like Hungarian group separator is the space character.

There is a higher risk that your date component separator is unexpected by the DBMS. SO:

  • Can you grab the SQL sent to database while running DisableBind = 1?
    This allows you the closest view possible to what is actually causing the error.
  • How do numeric values look?
  • How do date/time/datetime values look?

HTH /Michael

 

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.