Categories > TinyButStrong general >

TbsSQL: capture database error message

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: John Lawler
Date: 2013-06-07
Time: 00:56

TbsSQL: capture database error message

Is there any existing way to capture a database error message coming back from a statement I execute so that I can parse it and display it to my user separately (this is the type of error that may occasionally happen in normal production, because a stored procedure I call implements some business logic and may use RAISERROR in MSSQL to return a meaningful error message to the user).

I know this is probably not very typical of how people use TBS, but it would be helpful to have this capability.  I know about the various $Db->Modes I can set to either always hide the messages or always show them, but using the TBSSQL_NORMAL mode, I don't seem to be able to have any control to see the message first and choose where and how I display it to the user on my page.

Am I missing something, Skrol?  Or could this possibly be something you add in a future release?

By: Skrol29
Date: 2013-06-08
Time: 01:20

Re: TbsSQL: capture database error message

Hi John,

You're right, this feture is missing.
For now, yu can try
By: TomH
Date: 2013-12-10
Time: 04:34

Re: TbsSQL: capture database error message

Hello Skrol29;

I need to check for an error after TbsSQL  does $Db->Execute($sq): so that I can perform an edit/correction to form-submitted data entered if the $sql = "INSERT INTO $table ..." fails for any reason

I just found this post/thread and am trying to use your snip to get some info from TbsSQL like this
  $debug .= "<hr> \$tbs_sql->_Dbs_Error(false)=  ".$tbs_sql->_Dbs_Error(false)."<hr>";
  $message = "Duplicate entry, please change your selection and resubmit -- error " .$tbs_sql->_Dbs_Error(false)."<hr>";

My script returns "Call to a member function _Dbs_Error() on a non-object in /home/htdocs/subscribers.php on line 166"

Would you be so kind as to explain the correct way for me to make use of your snippet above, please?

Sincere thanks for any guidance you can provide.

Thanks for TBS (and TBSSQL) every day,

By: Skrol29
Date: 2013-12-11
Time: 22:12

Re: TbsSQL: capture database error message

Hi TomH,

What is your version of TbsSQL ?
By: TomH
Date: 2014-01-28
Time: 07:59

Re: TbsSQL: capture database error message

Sorry for the delay in responding

Using TbsSQL v 3.2