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 » MySQL and Sql class issue
MySQL and Sql class issue [message #6986] Wed, 06 December 2006 15:10 Go to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hello,

Has anyone tried to use MySql with the Sql class? I'm looking for an example similiar to the example for Sqlite.

Thanks,

Dave
Re: MySQL and Sql class issue [message #6988 is a reply to message #6986] Wed, 06 December 2006 16:53 Go to previous messageGo to next message
mezise is currently offline  mezise
Messages: 54
Registered: April 2006
Member
Yes, try 'SQL_MySql' package in 'reference' assembly (TheIDE dev version).

To compile:
1. You need mysql libs (while installing mysql under Windows just check dev files option)

2. TheIDE menu: Setup/Build methods../ - set correct paths to bin, include and lib directories.

3. If you compile using free MSC71 in Debug mode and have error about lacking file 'libcpmtd.lib' change method e.g. to Optimal.

Good luck!

Michal
Re: MySQL and Sql class issue [message #6991 is a reply to message #6988] Wed, 06 December 2006 19:03 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hello,

The SQL_MySql app performs all of its operations as part of main. What I am trying to do is access various SQL actions (insert, update, delete, select), from withing functions that are part of the main window class. I believe that i could simply use the "Execute" function, but I would prefer to use the functions in the Sql class.

As a side note, I am trying to use a schema file similiar to the one in the SQL_Sqlite3 example, however it doesn't seem to create the table or, if I create the table independantly, update the records in the table.

Thanks,

Dave
Re: MySQL and Sql class issue [message #6992 is a reply to message #6991] Wed, 06 December 2006 19:24 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, I guess the trick you need to know is the existence of "global SQL session/cursor".

It is represented by that "SQL" in examples. Once you assign anything to it, all Sql cursor will by default be assigned to this session. Of course, this works well only as long as your app uses just single database (but that is 90% cases).

Moreover, you also use this "SQL" as cursor to execute commands (but caution is needed there).

Mirek
Re: MySQL and Sql class issue [message #6993 is a reply to message #6992] Wed, 06 December 2006 19:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
P.S. If this explanation does not help, post some code or testcase.

Mirek
Re: MySQL and Sql class issue [message #6994 is a reply to message #6993] Wed, 06 December 2006 21:30 Go to previous messageGo to next message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Hello,

I'm still not sure how to get this to work correctly. I've attached the code that I've written.

Ps. I am still learning how to use Ultimate++ so please forgive the crude code.

Thanks,

Dave
  • Attachment: SQLApp.zip
    (Size: 2.47KB, Downloaded 9311 times)
Re: MySQL and Sql class issue [message #6995 is a reply to message #6994] Wed, 06 December 2006 22:25 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Well, constructor is about the worst place to do login Smile

It should look like this:

GUI_APP_MAIN
{
	MySqlSession session;
	if(!session.Connect("test", "welcome1", "example", "localhost")) {
		Exclamation("Can't connect with MySql\n");
		return;
	}

	SQL = session; // Use as global session

	SqlSchema sch;
	All_Tables(sch);
	if(sch.ScriptChanged(SqlSchema::UPGRADE))
		MySqlPerformScript(sch.Upgrade()); // Create schema without indexes, constraints etc...
	if(sch.ScriptChanged(SqlSchema::ATTRIBUTES)) {
		MySqlPerformScript(sch.Attributes()); // Add indexes, constraints...
	}
	if(sch.ScriptChanged(SqlSchema::CONFIG)) { // Fill with initial data if any
		MySqlPerformScript(sch.ConfigDrop());
		MySqlPerformScript(sch.Config());
	}
	sch.SaveNormal(); // Save as files for later use if needed

	SQLApp().Run();
}



Then remove "session" from MyApp and all Sql constructor leave default (sometimes you can use SQL instead of defining Sql - basicaly for all non-query statements, queries are somewhat risky )

Mirek

[Updated on: Wed, 06 December 2006 22:25]

Report message to a moderator

Re: MySQL and Sql class issue [message #7014 is a reply to message #6995] Thu, 07 December 2006 16:58 Go to previous message
dmcgeoch is currently offline  dmcgeoch
Messages: 52
Registered: November 2006
Location: New Jersey
Member
Thank you Mirek. That did the trick.

Dave
Previous Topic: mysql error
Next Topic: Compiling OLEDB using MINGW
Goto Forum:
  


Current Time: Mon Apr 29 02:58:29 CEST 2024

Total time taken to generate the page: 0.02481 seconds