WinCC OLE DB Provider error executing query

500 views Asked by At

So i have been trying to implement a module to access a database which using WiCC OLE DB Provider(Page 22 to 25). I can connect to the database using open method and i also successfully ping the database, but when i execute the query it returns error.

here's the query.

    TAG:R,'SystemArchive\\1511_AT_1379A/MS.PV_Out#Value','2022-02-08 07:35:00.000', '2022-02-08 07:40:00.000'

and here's the error log from the program i made.

Test Connection String :  Provider=WinCCOLEDBProvider.1;Persist Security Info=False;User ID="";Data Source=10.1.1.1\WINCC;Catalog=CC_OS_1__21_12_14_16_25_11R;Mode=Read;Location="";Mode=Read;Extended Properties=""

Sql Driver : [adodb]

Ping Successful!

Test Query :  TAG:R,'SystemArchive\1511_AT_1379A/MS.PV_Out#Value','2022-02-08 07:35:00.000', '2022-02-08 07:40:00.000'
Error Preparing Statement Exception occurred. (Provider cannot derive parameter information and SetParameterInfo has not been called.)

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x38 pc=0x864d82]

goroutine 1 [running]:
database/sql.(*Stmt).QueryContext(0x0, {0x8de310, 0xc00009e010}, {0x0, 0x0, 0x0})
        C:/Program Files/Go/src/database/sql/sql.go:2726 +0x82
database/sql.(*Stmt).Query(...)
        C:/Program Files/Go/src/database/sql/sql.go:2784
main.main()
        D:/tugas/Pagawean/MusaGreen/Repo/adodb-wincc-oledb/main.go:63 +0x45f

The point i take here is the provider cannot derive parameter information and the set parameter info has not been called. I have been trying to search across webs but i still havent managed to figure what the error exactly means and what the provider actually wants. Most cases i found is about the provider version x86 vs x64, which people prefer to use x86 and there is another one saying the error occured because of the provider bug so it needs to set the cursor within "ADODB.Connection" object. I have tried the second one by forking the library repo and modify the Open() method by adding this line

    _, err = oleutil.PutProperty(db, "CursorLocation", 3)
        if err != nil {
            return nil, err
        }
        val, err := oleutil.GetProperty(db, "Parameters")
        if err != nil {
            return nil, err
        }
        dbrc := val.ToIDispatch()
        val.Clear()

then i return the dbrc on return

    &AdodbConn{db: dbrc}, nil

Still no luck this far, is there anyone can point something out? is there anything i miss here?

kind regard thank you :)

0

There are 0 answers