Laurent95 Active Member Licensed User Longtime User Sep 17, 2015 #1 Hello, Edit : It's not really due to DBUtils i think, but i want to use a modified DBUtils module in my code, that's why i put this title. I have an interrogate. I get a Warrning # 1 (Unreachable code detected) in the IDE when i uses this code Code: Copy Sub TestWarning1(SQL As SQL) As String SQL.BeginTransaction Try 'Do anything you want SQL.TransactionSuccessful Return "Ok" Catch Return LastException.Message End Try SQL.EndTransaction But in example given by SQL Library, it's exactly like that it's showed how to use Begin/EndTransaction. I know i can ignore the warning, but if someone can tell me why ? Thanks. Laurent. Last edited: Sep 17, 2015
Hello, Edit : It's not really due to DBUtils i think, but i want to use a modified DBUtils module in my code, that's why i put this title. I have an interrogate. I get a Warrning # 1 (Unreachable code detected) in the IDE when i uses this code Code: Copy Sub TestWarning1(SQL As SQL) As String SQL.BeginTransaction Try 'Do anything you want SQL.TransactionSuccessful Return "Ok" Catch Return LastException.Message End Try SQL.EndTransaction But in example given by SQL Library, it's exactly like that it's showed how to use Begin/EndTransaction. I know i can ignore the warning, but if someone can tell me why ? Thanks. Laurent.
DonManfred Expert Licensed User Longtime User Sep 17, 2015 #2 Laurent95 said: but if someone can tell me why ? Click to expand... You are calling Code: Copy SQL.EndTransaction at the end of your sub. BUT you are using return statements... Code: Copy SQL.EndTransaction will never be called in your code. You should place the EndTransaction in the line just before the return "OK"... Upvote 0
Laurent95 said: but if someone can tell me why ? Click to expand... You are calling Code: Copy SQL.EndTransaction at the end of your sub. BUT you are using return statements... Code: Copy SQL.EndTransaction will never be called in your code. You should place the EndTransaction in the line just before the return "OK"...
Laurent95 Active Member Licensed User Longtime User Sep 18, 2015 #3 DonManfred said: BUT you are using return statements... Code: Copy SQL.EndTransaction will never be called in your code. You should place the EndTransaction in the line just before the return "OK"... Click to expand... Thank you so much Manfred for the quick reply That's evident, when i wrote the code i focused on another warning #2 (Not all code paths return a value), i think that's why i did this mistake . Mmmmmm, it seems sometime i will do better to do a little nap , already that i have difficulty to sleep actually . . Upvote 0
DonManfred said: BUT you are using return statements... Code: Copy SQL.EndTransaction will never be called in your code. You should place the EndTransaction in the line just before the return "OK"... Click to expand... Thank you so much Manfred for the quick reply That's evident, when i wrote the code i focused on another warning #2 (Not all code paths return a value), i think that's why i did this mistake . Mmmmmm, it seems sometime i will do better to do a little nap , already that i have difficulty to sleep actually . .