Status & Roadmap
Authors & License
Funding Ultimate++
Search on this site
Search in forums

SourceForge.net Logo
Today's Messages (off)  | Unanswered Messages (on)

Forum: U++ community news and announcements
 Topic: svn/github now has auto-generated Makefile
svn/github now has auto-generated Makefile [message #53461] Sat, 04 April 2020 14:18
mirek is currently offline  mirek
Messages: 12329
Registered: November 2005
Ultimate Member
(now on to write good README)
Forum: Newbie corner
 Topic: OptionTree inside a DropTree
OptionTree inside a DropTree [message #53421] Thu, 02 April 2020 11:41
idkfa46 is currently offline  idkfa46
Messages: 135
Registered: December 2011
Experienced Member
I need to allow multiple selections between around 10 options that why I was thinking about an OptionTree with one node inside a DropTree (to reduce space). Is it something possible?

Forum: U++ SQL
 Topic: MSSQL Exception Handling
MSSQL Exception Handling [message #53447] Fri, 03 April 2020 12:11
Pradip is currently offline  Pradip
Messages: 18
Registered: February 2019
Location: India
Promising Member
Hi there,

Hope everyone is safe during this COVID threat! Stay indoors, stay safe, please!

Since we must work-from-home, we are faced with situations where the VPN connection is not stable, so the mssql connection can break anytime. Our app needs to be able to reconnect, in case it gets disconnected while running a query.

With this idea, I'm trying the following:

connection code (works fine):
MSSQLSession mssql;

bool ConnectMSSql() {
	String cs = "Driver={SQL Server Native Client 11.0};";
	cs << "Server=***;";
	cs << "UID=***;";
	cs << "PWD=***;";
	cs << "Database=***;";

			Format("\1Connection to database server failed:\n%s", mssql.GetLastError())
			return false;
	SQL = mssql;
	return true;

code for re-connection:
this also works, but SQL.GetErrorCode() == 0 must be very wrong. All I want to do here is "only if connection is broken the run connect", but SQL.GetErrorCode() seems to always return 0, no matter if the error is due to disconnection or sql logic error! I've tried SQL.GetErrorClass() == Sql::CONNECTION_BROKEN, but it didn't seem to work.
bool ReconnectMSSql() {
	return SQL.GetErrorCode() == 0 && ConnectMSSql(); // is error code right?

finally, code for queries:
this is the biggest question: do i have to use the same syntax for every query in the app? also for Select queries? till now i've used try...catch only for Update and Insert queries.
		bool retry;
		do {
			retry = false;
			try { // set start date
				q & ::Update(ACTIVITIES)(startDtId, newStartDt).Where(ACT_ID == Id);
			catch(SqlExc &e) {
				if(ReconnectMSSql()) retry = true;
				else {
					Exclamation("[* " + DeQtfLf(e) + "]");
					return false;
		} while(retry);

Is there any easier way to do this, so that anytime a query is executed it will check the connection status and reconnect if needed?

Thanks in advance for helping!

[Updated on: Sat, 04 April 2020 05:35]

Report message to a moderator

 Topic: Copy from stdin (PostgreSQL) support in U++ SQL
Copy from stdin (PostgreSQL) support in U++ SQL [message #53427] Thu, 02 April 2020 20:41
shutalker is currently offline  shutalker
Messages: 15
Registered: November 2017
Location: Moscow
Promising Member
Hi all!
Is it possible to execute
COPY table_name FROM STDIN
via Sql interface?
I'm trying to do something like this
PostgreSQLSession pgSession;
if (!pgSession.Open("dbname=postgres user=postgres")) {
	RLOG("failed to setup postgresql session");
Sql sql(pgSession);

// Is there a way to setup any IO stream for data transfer?
if (!sql.Execute("COPY my_test_table FROM STDIN")) {
	RLOG("failed to copy data from client: " << sql.GetLastError());

But I don't know how to transfer data I want to import into database.

UPD: I've made a temporary dirty hack that works. This hack requires psql client to be installed
        LocalProcess psqlClient;
	String psqlCopyCmd = Format("\\COPY \"%s\" FROM STDIN", tableName);

	if (!psqlClient.Start("psql", {config["database"]["init"], "-c", psqlCopyCmd}))
	    throw String("failed to run psql client in child process");


        String copyLine;

	String exitMessage;

	if (psqlClient.GetExitCode() != 0)
	    throw Format("failed to import 3d-data into database: %s", exitMessage);

[Updated on: Fri, 03 April 2020 14:35]

Report message to a moderator

Current Time: Wed Apr 08 10:12:26 CEST 2020

Total time taken to generate the page: 0.01169 seconds