Forum Discussion
juctn
Apr 18, 2023Copper Contributor
JetAttachDatabase end with error code -1032 (file is locked or in use)
Hello there,
So, I'm trying to developp a Go application working with ESE databases.
I'm using Syscall to call "ESENT.dll" functions to access and read data from ESE files.
Regarding the ESE handles documentation from Microsoft, I first have to create and initiate an instance, then begin a session, and finally attach and open the database before I can read data.
I made some tests using an ESE database (SRUM database : SRUDB.dat), dumped from my own compter.
When calling functions "JetCreateInstance", "JetInit" and "JetBeginSession", I don't have any error (error code 0 : the function succeeded).
But, when calling "JetAttachDatabase", it end with error code -1032 (The file cannot be accessed because the file is locked or in use).
Could you please help me with this?
Thanks!
This is my Go code for the JetAttachDatabase function :
func JetAttachDatabase(sesid JET_SESID, pesedbPath unsafe.Pointer) {
fmt.Print("Call JetAttachDatabase... ")
//JET_ERR JET_API JetAttachDatabase(
// __in JET_SESID sesid,
// __in const tchar* szFilename,
// __in JET_GRBIT grbit
// );
ret, _, err := esentDLL.NewProc("JetAttachDatabase").Call(
uintptr(sesid),
uintptr(pesedbPath),
0,
)
error.EsentCallErrorHandle(error.JET_ERR(ret), err)
}
My var and function call :
type JET_API_PTR uint64
type JET_INSTANCE JET_API_PTR
type JET_SESID JET_API_PTR
type JET_DBID uint64
var instance JET_INSTANCE
var sesid JET_SESID
var dbid JET_DBID
esedbPath = ".\\esedbfiles\\SRUDB.dat"
pesedbPath, err := syscall.UTF16PtrFromString(esedbPath)
if err != nil {
os.Exit(1)
}
JetAttachDatabase(sesid, unsafe.Pointer(pesedbPath))
No RepliesBe the first to reply