Calling stored procedure from MS Access results in error 3146

Calling stored procedure from MS Access results in error 3146



When I call a SQL Server stored procedure from MS Access front-end using the code shown below, it stops running and throws the runtime error "3146".



This stored procedure is working correctly in SQL Server, but when I run from MS Access, it is working at first, but suddenly stops and throws that runtime error "3146".



For more clearance this stored procedure is for inserting records in an empty table when I do from MS Access it should insert 1000 records, but it inserts 970 records and then stops.



My stored procedure had a select query for inserting records, now I have changed this easy select query to a union query, since I have changed this in the design of stored procedure it is working fine in SQL Server


Public Sub Command0_Click()
Dim qdef As DAO.QueryDef
Set qdef = CurrentDb.CreateQueryDef("")

qdef.Connect = CurrentDb.TableDefs("[ASBUILT_LIST]").Connect
qdef.SQL = "EXEC Update_Asbuilt2"
qdef.ReturnsRecords = False ''avoid 3065 error
qdef.Execute
qdef.Close

Set qdef = Nothing
End Sub






As it runs but not to the end I assume a permission problem. On error 3146 loop through the Errors Collection with For I = 0 To Errors.Count-1 Debug.Print Errors(I) Next I

– ComputerVersteher
Sep 8 '18 at 10:24


For I = 0 To Errors.Count-1 Debug.Print Errors(I) Next I




1 Answer
1



If it runs, but not until the end, then it is probably not a permission problem, but a timeout problem



you can do a :


debug.print qdef.ODBCTimeout



to know what your current Timeout value is.



Then just increase it with enough seconds to complete the stored procedure :


Public Sub Command0_Click()
Dim qdef As DAO.QueryDef
Set qdef = CurrentDb.CreateQueryDef("")

qdef.Connect = CurrentDb.TableDefs("[ASBUILT_LIST]").Connect
' --------------- Define TimeOut in Seconds ----------------
qdef.ODBCTimeout = 2000
' ----------------------------------------------------------
qdef.SQL = "EXEC Update_Asbuilt2"
qdef.ReturnsRecords = False ''avoid 3065 error
qdef.Execute
qdef.Close

Set qdef = Nothing
End Sub






thanks my qdef.ODBCTimeout was 60, i do not know how it was 60, and i had not changed it's default value before.

– Masoud Sedighi
Sep 8 '18 at 11:00






Default is 60 seconds ;-)

– Thomas G
Sep 8 '18 at 11:01



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

How do I collapse sections of code in Visual Studio Code for Windows?