Symptom

Application migrated from PowerBuilder 11.5 to PowerBuilder 2017 and connecting to Microsoft SQL Server using ODBC. 

When retrieving a  DataWindow, that is calling a stored procedure, using a datetime argument causes the application to stop working.     

A ODBC trace shows the following error:

SDWORD -3
WCHAR * 0x0018BD72 [ 2] " \ 0"
SDWORD 2
SDWORD * 0x0018BD54 (296)

DIAG [01004] [Microsoft][ODBC SQL Server Driver]String data, right truncation (0)

Environment

  • PowerBuilder
  • ODBC
  • Microsoft SQL Server
  • Windows 7

Reproducing the Issue

1.  Start PowerBuilder on Windows 7.

2.  Open the Database Profiles and expand the 'ODB ODBC' interface and then expand the 'Utilities' under the ODB ODBC.

3.  Doubleclick on the ODBC Administrator (this will start the 32-bit version of the ODBC Administrator).

4.  Select the Tracing tab and click on the 'Start Tracing Now' commandbutton.

 odbc.png

5.  Go back to the DataBase Profiles and connect to the ODBC Microsoft SQL Server database.

6.  Create a new DataWindow using a Stored Procedure as the datasource.   (Ensure that the stored procedure has a input argument of datetime.)

7.  Create a window and DataWindow control.   Associate the DataWindow object to the DataWindow control.

8.  In the window's open event, add script to connect to the Microsoft SQL Server database using ODBC and retrieves the DataWindow.

9.  Make sure that you use the dbparms of DisableBind=1 and CallEscape='No' and PBNewSPInvocation='No' when connecting to the Microsoft SQL Server database.

10.  Run the powerscript that you just created and notice that the DataWindow stops working.

11.  Open  the SQL.log file and you will also see the error of 'String data, right truncation'.

Cause

Incompatibility with ODBC API SQLDescribeParam

Resolution

Use PBNewSPInvocation='YES' instead of PBNewSPInvocation='No'

0
0