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 » [solved]crash when execute sql command
[solved]crash when execute sql command [message #46602] Thu, 09 June 2016 05:40 Go to next message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
i use MSSQL, i don`t know why this happened! Sad please see the code:

void ConnectMSSQL()
{
	MSSQLSession mssql;
	for(;;) {
		String cs = "Driver={SQL Server};";
		cs << "SERVER=" << Config::ip << ';';
		String h = "sa";
		if(IsNull(h))
			cs << "Trusted_Connection=Yes;";
		else {
			cs << "UID=" << h << ';';
			cs << "PWD=" << "YanG78lNa4diw3ATs" << ';';
			h = "";
			if(IsNull(h))
				cs << "Database=" << h << ';';
		}
		if(!mssql.Connect(cs))
		{
			RLOG("Connect failed: " << mssql.GetLastError());
			Cout() << "failed\n";
			return;
		}
		else
			break;
	}
	SQL = mssql;

#ifdef _DEBUG
	mssql.SetTrace();
#endif
String sqlstr = "select * from TEST";
	SQL.Execute(sqlstr);
}

CONSOLE_APP_MAIN
{
ConnectMSSQL();

}


it`s no problem!

void ConnectMSSQL()
{
	MSSQLSession mssql;
	for(;;) {
		String cs = "Driver={SQL Server};";
		cs << "SERVER=" << Config::ip << ';';
		String h = "sa";
		if(IsNull(h))
			cs << "Trusted_Connection=Yes;";
		else {
			cs << "UID=" << h << ';';
			cs << "PWD=" << "YanG78lNa4diw3ATs" << ';';
			h = "";
			if(IsNull(h))
				cs << "Database=" << h << ';';
		}
		if(!mssql.Connect(cs))
		{
			RLOG("Connect failed: " << mssql.GetLastError());
			Cout() << "failed\n";
			return;
		}
		else
			break;
	}
	SQL = mssql;

#ifdef _DEBUG
	mssql.SetTrace();
#endif
}

void Query(
{
String sqlstr = "select * from TEST";
	SQL.Execute(sqlstr);

}

CONSOLE_APP_MAIN
{
ConnectMSSQL();
Query();

}


it crash!

[Updated on: Tue, 21 June 2016 09:19]

Report message to a moderator

Re: crash when execute sql command [message #46603 is a reply to message #46602] Thu, 09 June 2016 05:59 Go to previous message
akebee is currently offline  akebee
Messages: 90
Registered: August 2011
Location: China
Member
ok! i know !because the session is closed!
Previous Topic: Global SqlIds
Next Topic: [solved]when to reconnect to the sql database?
Goto Forum:
  


Current Time: Sat Jun 22 23:56:33 CEST 2024

Total time taken to generate the page: 0.01777 seconds