U++ framework
Do not panic. Ask here before giving up.

Home » U++ Library support » U++ SQL » ODBC Assertion failed
Re: ODBC Assertion failed [message #55851 is a reply to message #55850] Tue, 22 December 2020 18:49 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14291
Registered: November 2005
Ultimate Member
One little issue: You are supposed to use Begin/End/Commit with your session, not query - that is deprecated. But in fact, the result should be the same (it just calls GetSession().Begin().. etc...)

For what is worth, I have altered SQL_MSSQL reference example to check the issue:

#include "app.h"

#include <Sql/sch_schema.h>
#include <Sql/sch_source.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	MSSQLSession mssql;
	if(!mssql.Connect("Driver={SQL Server Native Client 11.0};Server=localhost;Database=master;Trusted_Connection=Yes;")) {
		Cout() << "Connect failed: " << mssql.GetLastError() << '\n';
		return;
	}
	
	SQL = mssql;

	SqlSchema sch(MSSQL);
	StdStatementExecutor se(SQL.GetSession());
	All_Tables(sch);
	ODBCPerformScript(sch.Upgrade(), se);
	ODBCPerformScript(sch.Attributes(), se);

#ifdef _DEBUG
	mssql.SetTrace();
	mssql.LogErrors();
	mssql.ThrowOnError();
#endif

	
	SQL.Begin();
	try {
		for(int i = 0; i < 10; i++)
			SQL * Insert(TEST)(ID, i)(TEXT, String('A' + i, 1));
	}
	catch(SqlExc e)
	{
		DDUMP(e);
	}
	
	if(SQL.WasError()) {
		DLOG("There was ERROR!");
		SQL.Rollback();
	}
	else
		SQL.Commit();
	
	S_TEST tst;
	Sql sql;
	sql * Select(tst).From(TEST);
	while(sql.Fetch(tst))
		Cout() << tst.ID << ", " << tst.TEXT << '\n';
}


and everything works as expected...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: OleDBSession in Archive
Next Topic: sqlite3 Custom Function in SqlExp
Goto Forum:
  


Current Time: Sun May 10 21:29:58 GMT+2 2026

Total time taken to generate the page: 0.00744 seconds