mattn / go-adodb

Microsoft ActiveX Object DataBase driver for go that using exp/sql
http://mattn.kaoriya.net/
MIT License
142 stars 36 forks source link

execute query result is nothing, raise an exception #36

Open jingcsdn opened 6 years ago

jingcsdn commented 6 years ago

sorry, my English is very bad... when execute Query is no data result(no columns, no data), result rows is not nil but exec rows.Next() raise an error

jingcsdn commented 6 years ago

go1.10.2 run with windows server 2008

mattn commented 6 years ago

Please show me minimal code to reproduce.

jingcsdn commented 6 years ago

sql server code CREATE PROCEDURE [dbo].[P_SE_TEST_NO_RETURN] As SET NOCOUNT ON; Update TableName Set ColumnName='123' where 1=2 return

go code connstr := "Provider=SQLOLEDB;Data Source=IP;Initial Catalog=dbname;user id=username;password=xxxx" db, _ := sql.Open("adodb", connstr) defer db.Close() rows, _ := db.Query("exec P_SE_TEST_NO_RETURN") defer rows.Close() cols, _ := rows.Columns() values := make([]interface{}, len(cols)) scanArgs := make([]interface{}, len(values)) for i := range values { scanArgs[i] = &values[i] } for rows.Next() { //This line of code throws an exception //... }

i know, if no return values, i should be use db.exec(sql)... but some times sql coding error...

mattn commented 6 years ago

What the error did you get?

jingcsdn commented 6 years ago

sorry, it's my fault... i found the error , throws an exception with db.Close()

connstr := Provider=SQLOLEDB;Data Source=10.0.11.60;Initial Catalog=HNTMP;user id=username;password=pwd db, := sql.Open("adodb", connstr) defer func() { log.Println("exec db close....") db.Close() log.Println("db close success....") }() rows, := db.Query(exec P_SY_in_Annex) defer func() { log.Println("exec rows close....") rows.Close() log.Println("rows close success....") }() log.Println(exec 1) for rows.Next() { // ... } log.Println("exec 2")

2018/07/31 10:48:54 exec 1 2018/07/31 10:48:54 exec 2 2018/07/31 10:48:54 exec rows close.... 2018/07/31 10:48:54 rows close success.... 2018/07/31 10:48:54 exec db close.... Exception 0xc0000005 0x8 0x0 0x0 PC=0x0 syscall.Syscall9(0x7ff943123640, 0x9, 0x9a2ad0, 0x5, 0xc0420541b0, 0x804, 0x1, 0xc042071618, 0xc0420b4f40, 0xc042071a58, ...) C:/Go/src/runtime/syscall_windows.go:197 +0x102 github.com/go-ole/go-ole.invoke(0x9a2ad0, 0x100000005, 0x0, 0x0, 0x0, 0xc0420b4f40, 0x0, 0x0) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/idispatch_windows.go:175 +0x216 github.com/go-ole/go-ole.(IDispatch).Invoke(0x9a2ad0, 0x100000005, 0x0, 0x0, 0x0, 0x0, 0xc042071b98, 0x43bd2e) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/idispatch.go:27 +0x62 github.com/go-ole/go-ole.(IDispatch).InvokeWithOptionalArgs(0x9a2ad0, 0x5062ab, 0x5, 0x4a0001, 0x0, 0x0, 0x0, 0x5b93e0, 0x0, 0x0) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/idispatch.go:69 +0x99 github.com/go-ole/go-ole/oleutil.CallMethod(0x9a2ad0, 0x5062ab, 0x5, 0x0, 0x0, 0x0, 0xc042071c68, 0x428bab, 0x51d4e0) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/oleutil/oleutil.go:51 +0x75 github.com/mattn/go-adodb.(AdodbConn).Close(0xc042074028, 0x8, 0xc042050000) C:/Users/hydewu/go/src/github.com/mattn/go-adodb/adodb.go:140 +0x5f database/sql.(driverConn).finalClose.func2() C:/Go/src/database/sql/sql.go:483 +0x50 database/sql.withLock(0x51d4c0, 0xc0420a2000, 0xc042071d10) C:/Go/src/database/sql/sql.go:3032 +0x6a database/sql.(driverConn).finalClose(0xc0420a2000, 0xc04204ed00, 0xc0420a2020) C:/Go/src/database/sql/sql.go:481 +0x115 database/sql.(finalCloser).(database/sql.finalClose)-fm(0xc04204c0b8, 0xc042068420) C:/Go/src/database/sql/sql.go:580 +0x36 database/sql.(DB).Close(0xc04204c0a0, 0x1, 0x1) C:/Go/src/database/sql/sql.go:740 +0x2a9 main.test.func2(0xc04204c0a0) C:/Users/hydewu/Desktop/testdb/db.go:76 +0x76 main.test() C:/Users/hydewu/Desktop/testdb/db.go:90 +0x1a3 main.main() C:/Users/hydewu/Desktop/testdb/db.go:93 +0x2d goroutine 18 [select]: database/sql.(DB).connectionOpener(0xc04204c0a0, 0x51d740, 0xc042050080) C:/Go/src/database/sql/sql.go:935 +0x120 created by database/sql.OpenDB C:/Go/src/database/sql/sql.go:634 +0x17f goroutine 19 [select]: database/sql.(DB).connectionResetter(0xc04204c0a0, 0x51d740, 0xc042050080) C:/Go/src/database/sql/sql.go:948 +0x131 created by database/sql.OpenDB C:/Go/src/database/sql/sql.go:635 +0x1b5 rax 0x0 rbx 0x9eeb90 rcx 0x9eaf50 rdi 0x0 rsi 0x9eeb90 rbp 0x7bf7e0 rsp 0x7bf698 r8 0x9eebb0 r9 0x0 r10 0x9c8ff0 r11 0x7bf4b0 r12 0x1 r13 0x995d40 r14 0x995d40 r15 0x0 rip 0x0 rflags 0x10202 cs 0x33 fs 0x53 gs 0x2b

吴思静 jing.csdn@gmail.com 于2018年7月31日周二 上午10:33写道:

connstr := Provider=SQLOLEDB;Data Source=10.0.11.60;Initial Catalog=HNTMP;user id=username;password=pwd db, := sql.Open("adodb", connstr) defer db.Close() rows, := db.Query(exec P_SY_in_Annex) // cols, _ := rows.Columns() // if len(cols) == 0 { // return // } defer rows.Close() log.Println(123) for rows.Next() { //This line of code throws an exception // ... }

Exception 0xc0000005 0x8 0x4b 0x4b PC=0x4b syscall.Syscall9(0x7ff92c283640, 0x9, 0x10f520, 0x5, 0xc0420541b0, 0x804, 0x1, 0xc042071670, 0xc0420b2ec0, 0xc042071ab0, ...) C:/Go/src/runtime/syscall_windows.go:197 +0x102 github.com/go-ole/go-ole.invoke(0x10f520, 0x100000005, 0x0, 0x0, 0x0, 0xc0420b2ec0, 0x0, 0x0) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/idispatch_windows.go:175 +0x216 github.com/go-ole/go-ole.(IDispatch).Invoke(0x10f520, 0x100000005, 0x0, 0x0, 0x0, 0x0, 0xc042071bf0, 0x43bd2e) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/idispatch.go:27 +0x62 github.com/go-ole/go-ole.(IDispatch).InvokeWithOptionalArgs(0x10f520, 0x5060ae, 0x5, 0x4a0001, 0x0, 0x0, 0x0, 0x5b93e0, 0x0, 0x0) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/idispatch.go:69 +0x99 github.com/go-ole/go-ole/oleutil.CallMethod(0x10f520, 0x5060ae, 0x5, 0x0, 0x0, 0x0, 0xc042071cc0, 0x428bab, 0x51d240) C:/Users/hydewu/go/src/github.com/go-ole/go-ole/oleutil/oleutil.go:51 +0x75 github.com/mattn/go-adodb.(AdodbConn).Close(0xc042074028, 0x8, 0xc042050000) C:/Users/hydewu/go/src/github.com/mattn/go-adodb/adodb.go:140 +0x5f database/sql.(driverConn).finalClose.func2() C:/Go/src/database/sql/sql.go:483 +0x50 database/sql.withLock(0x51d220, 0xc0420a2000, 0xc042071d68) C:/Go/src/database/sql/sql.go:3032 +0x6a database/sql.(driverConn).finalClose(0xc0420a2000, 0xc04204ed00, 0xc0420a2020) C:/Go/src/database/sql/sql.go:481 +0x115 database/sql.(finalCloser).(database/sql.finalClose)-fm(0xc04204c0b8, 0xc042068420) C:/Go/src/database/sql/sql.go:580 +0x36 database/sql.(DB).Close(0xc04204c0a0, 0x5d, 0xc04204c0a0) C:/Go/src/database/sql/sql.go:740 +0x2a9 main.test() C:/Users/hydewu/Desktop/testdb/db.go:91 +0x15c main.main() C:/Users/hydewu/Desktop/testdb/db.go:94 +0x2d goroutine 18 [select]: database/sql.(DB).connectionOpener(0xc04204c0a0, 0x51d4a0, 0xc042050080) C:/Go/src/database/sql/sql.go:935 +0x120 created by database/sql.OpenDB C:/Go/src/database/sql/sql.go:634 +0x17f goroutine 19 [select]: database/sql.(DB).connectionResetter(0xc04204c0a0, 0x51d4a0, 0xc042050080) C:/Go/src/database/sql/sql.go:948 +0x131 created by database/sql.OpenDB C:/Go/src/database/sql/sql.go:635 +0x1b5 rax 0x4b rbx 0x157430 rcx 0x1548f0 rdi 0x0 rsi 0x157430 rbp 0x7bf7e0 rsp 0x7bf698 r8 0x157450 r9 0x0 r10 0x10fbc0 r11 0xffffff r12 0x1 r13 0x103630 r14 0x103630 r15 0x0 rip 0x4b rflags 0x10202 cs 0x33 fs 0x53 gs 0x2b

mattn notifications@github.com 于2018年7月30日周一 下午6:13写道:

What the error did you get?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mattn/go-adodb/issues/36#issuecomment-408815297, or mute the thread https://github.com/notifications/unsubscribe-auth/ADQPFC7MXzMJ2xzGYo4v31u5wX3D9Z2Rks5uLtw4gaJpZM4VhR2Z .