Raised This Month: $ Target: $400
 0% 

Database reconnect on lost connection?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
foon
Member
Join Date: Dec 2018
Old 04-29-2020 , 22:25   Database reconnect on lost connection?
Reply With Quote #1

Im wondering, when you make a connection to a database and you lose connection to it, will it auto-reconnect on the next map start, or do I have to connect again?

Example, do I have to do this or can I get rid of the "OnMapStart()"?
Code:
Database g_hDatabase = null;

public void OnPluginStart()
{
	Database.Connect(SQL_Connection, "db");
}

public void OnMapStart()
{
	if (g_hDatabase == null)
	{
		Database.Connect(SQL_Connection, "db");
	}
}


public void SQL_Connection(Database hDatabase, const char[] sError, int iData)
{
	if (hDatabase == null)
	{
		ThrowError(sError);
	}
	else
	{
		g_hDatabase = hDatabase;
		
		PrintToServer("[SQL] Connected to DB.");
		return;
	}
}
foon is offline
 



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 02:49.


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