Raised This Month: $51 Target: $400
 12% 

SQL Problem crashing my server!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fragnichtnach
AlliedModders Donor
Join Date: Oct 2008
Old 01-05-2019 , 15:36   SQL Problem crashing my server!
Reply With Quote #1

Code:
LogError("DB_Connect start connecting");
g_Db = SQL_Connect(SQLTable, false, Error, sizeof(Error));
LogError("DB_Connect connected");
This is crashing my server if the database is offline! I see only "DB_Connect start connecting" in the logs and the server is directly crashing after the startup. If the database is running, there are no problems. Anything I could do against the crash? Don't want to crash my server, just because the database is not running.

Last edited by fragnichtnach; 01-05-2019 at 15:38.
fragnichtnach is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 01-05-2019 , 15:43   Re: SQL Problem crashing my server!
Reply With Quote #2

Try using SQL_TConnect
__________________

Last edited by 8guawong; 01-05-2019 at 15:44.
8guawong is offline
fragnichtnach
AlliedModders Donor
Join Date: Oct 2008
Old 01-05-2019 , 18:21   Re: SQL Problem crashing my server!
Reply With Quote #3

Okay, thanks. That looks good. Having a callback should handle this.

If I'm combining this correct, I have to rewrite a lot more than just the "T" in SQL_Connect.
fragnichtnach is offline
brunoronning
Senior Member
Join Date: Jan 2014
Location: Brazil
Old 01-05-2019 , 19:26   Re: SQL Problem crashing my server!
Reply With Quote #4

Quote:
Originally Posted by fragnichtnach View Post
Okay, thanks. That looks good. Having a callback should handle this.

If I'm combining this correct, I have to rewrite a lot more than just the "T" in SQL_Connect.
Example code:
PHP Code:
Handle g_Db null;

public 
void OnPluginStart()
{
    
SQL_TConnect(SQLCallback_OnConnect"blah");
}

public 
void SQLCallback_OnConnect(Handle ownerHandle hndl, const char[] errorany data)
{
    if (
hndl == null || strlen(error) > 0) {
        
LogError("Connection to database failed: %s"error);
    }
    else
    {
        
g_Db hndl;

        
// Your code...
    
}

__________________

Last edited by brunoronning; 01-05-2019 at 19:26.
brunoronning is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode