Closed badsector998 closed 2 years ago
Please try to git pull latest changes and do
import (
...
"github.com/mattn/go-adodb"
)
func main() {
sql.Register("adodb_with_cursorlocation", &adodb.AdodbDriver{
CursorLocation: 3,
})
db, err := sql.Open("v", "Provider="+provider+";Data Source="+f+";")
if err != nil {
fmt.Println("open", err)
return
}
...
}
Wonderful. The set cursor location method you added made the query execution executed successfully. Would you be so kind to elaborate more about your library? I mean executing the query would be the second step, next thing is i have to prepare an "ADODB.RecordSet" object to contain the query result. Does the db.Query()
method can handle the query result or support as "ADODB.RecordSet" ?
for row.Next() {
var (
valueId int
timeStamp string
realValue string
quality string
flags string
)
// var valueName string
err = row.Scan(&valueId, &timeStamp, &realValue, &quality, &flags)
if err != nil {
fmt.Println("Row Error : ", err)
}
fmt.Println(valueId, timeStamp, realValue, quality, flags)
}
I already provided above line in my code to contain the values but the fmt.Println
doesnt return any result though.
I tried to declare my own ADODB.Recordset
but from go-ole oleutils.CreateObject("ADODB.RecordSet")
, it makes the variable type to become ole.IUknown
type. Of course i cannot store sql.Rows()
result into ole.IUnknown
, since the compiler itself complains about it. I also tried to study from your functions, then again i still have no idea of how did you make these ole
based type into standard sql
.
Edit : So I also have been playing around a little bit using "go-ole" package. So i was wondering how can i convert a variable from *ole.IUnknown
to *ole.VARIANT
as for i want to create an ADODB.Recordset
using oleutils.CreateObject("ADODB.RecordSet")
then i want to use the variable to store return value from "Execute" command(or Query()
method?
Sorry for late reply but the sql.query()
doing just fine. Thank you :)
So i have been trying to implement this module to access a database which using WinCC 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.
and here's the error log from the program i made.
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 this repo and modify the
Open()
method by adding this linethen 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 :)