Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Added code to MySqlSession::DoConnect() correct?
icon5.gif  Added code to MySqlSession::DoConnect() correct? [message #40279] Mon, 15 July 2013 00:29 Go to next message
Alboni is currently offline  Alboni
Messages: 203
Registered: January 2012
Location: Deventer, Netherlands
Experienced Member
Gentlemen,

I added some code to MySqlSession::DoConnect() so I could retrieve the proper errormessage if Connect would fail.
My question: Am I using the proper variables for this or could this disrupt something ?

bool MySqlSession::DoConnect()
{
	mysql = mysql_init((MYSQL*) 0);
	level = 0;
	if(mysql)
	{
		if (mysql_real_connect(mysql, sEmpNull(connect_host), sEmpNull(connect_user),
	                               sEmpNull(connect_password), sEmpNull(connect_database),
	                               connect_port, sEmpNull(connect_socket), 0)) 
		{
			Sql sql(*this);
			username = sql.Select("substring_index(USER(),'@',1)");
			mysql_set_character_set(mysql, "utf8");
			sql.Execute("SET NAMES 'utf8'");
			sql.Execute("SET CHARACTER SET utf8");
			return true;
		}
/*added*/	errorcode_number=mysql_errno(mysql);
/*added*/	errorcode_string=mysql_error(mysql);
/*added*/	lasterror=errorcode_string; // what's the difference?
	}
	Close();
	return false;
}

Re: Added code to MySqlSession::DoConnect() correct? [message #40350 is a reply to message #40279] Mon, 22 July 2013 22:24 Go to previous message
mirek is currently offline  mirek
Messages: 13045
Registered: November 2005
Ultimate Member
I guess using SetError would perhaps be better here...

Mirek
Previous Topic: MS SQL Server CE Assistance
Next Topic: Call external funcions in SQL
Goto Forum:
  


Current Time: Fri Jan 22 04:45:08 CET 2021

Total time taken to generate the page: 0.01523 seconds