简体   繁体   中英

MSDataShape error, broken on upgrade to Windows 10 Feature Update 1809

In our VB6 application, we use ADODB.Recordsets and make use of the Data provider for MSDataShape to create a relational recordset with SHAPE commands.

In the latest Windows 10 Feature (1809) our code breaks with the following error: -

"-2147217900 Length of NEW column SiteCode cannot be zero"

from the following macro in excel (where MDAC is a reference)

Public Sub TestRun()
    Dim rsStockCheck As Recordset

    On Error GoTo ErrorHandler

    ' set up shape recordset
    Set rsStockCheck = New Recordset
    With rsStockCheck
        .ActiveConnection = "Provider=MSDataShape;Data Provider=None"
        .CursorLocation = adUseClient
        .CursorType = adOpenStatic
        .LockType = adLockBatchOptimistic
        .Open "SHAPE APPEND new adInteger as StockCheckID, new adInteger as SiteID, new adVarChar(8) as SiteCode"
        .ActiveConnection = Nothing
    End With

ErrorHandler:
    If Err.Number <> 0 Then
        MsgBox "failed: " & Err.Description
    Else
        MsgBox "works ok"
    End If

    Set rsStockCheck = Nothing
End Sub

This might be related to this being eventually removed as mentioned here .

... but I'm not sure if it is just yet. Has anyone come across this problem?


EDIT : I've tried this on an upgraded machine and Fresh install of 1809 and it's broken on both.


EDIT 2 : List of other forum threads regarding this issue:

EDIT 3 : Latest Nov 13 update for Windows 1809, still does not fix this issue. For a workaround however, read this .

Same problem with me ... However, I have found the workaround for this issue ... Replacing adVarChar(##) with adLongVarChar does the job for me ...

Please reply, if anyone has another solution

Edited: This workaround is not applicable to queries like

SHAPE APPEND NEW adLongVarChar As INVNO, NEW adLongVarChar As iCP,
((SHAPE APPEND NEW aadLongVarChar As INVNO,NEW adLongVarCharAs iCP,NEW adLongVarChar As F1,NEW adLongVarChar As F2,NEW adLongVarChar As F3)
AS Trans RELATE INVNO TO INVNO,iCP TO iCP)

Finding a solution to get out of this issue

EDIT : This error has been fixed in recent windows update (Version: 1809 OS Build : 17763.475). Everything working fine for me.

I've found a solution that works in all scenarios.

Instead of adVarChar(size) use the OLEDB datatype DBTYPE_BSTR . For example, instead:

SHAPE APPEND NEW adVarChar(8) As INVNO, NEW adVarChar(8) As iCP,
((SHAPE APPEND NEW adVarChar(8) As INVNO,NEW adVarChar(8) As iCP...)
AS Trans RELATE INVNO TO INVNO,iCP TO iCP)

write:

SHAPE APPEND NEW DBTYPE_BSTR As INVNO, NEW DBTYPE_BSTR As iCP,
((SHAPE APPEND NEW DBTYPE_BSTR As INVNO,NEW DBTYPE_BSTR As iCP...)
AS Trans RELATE INVNO TO INVNO,iCP TO iCP)

Notes:

  1. DBTYPE_BSTR doesn't accept the size of the field, so it's not exactly a varchar
  2. I had to use DBTYPE_BSTR keyword, using adBSTR produced an error message in the command (?!).

While this doesn't directly answer your question, MSDataShape is obsolete and being removed.

Suggest that you port your queries to FROM XML and change your client to parse the response using SAX or a pull parser.

It seems changing SHAPE APPEND new adVarChar(8) as SiteCode to SHAPE APPEND new adLongVarChar as SiteCode causes that SiteCode can not be a sort key.

However it seems SiteCode_Calc of SHAPE APPEND new adLongVarChar as SiteCode,calc(Left$(SiteCode,8)) as SiteCode_Calc can be a sort key.

However it seems MoveNext/EOF won't work correctly when the value of SiteCode_Calc is gotten.

正如@Shrikant所提到的,这是在最近的Windows更新(版本:1809 OS Build:17763.475)中修复的,并且还确认它已在1903年修复。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM