|
|
Home » Community » Newbie corner » mySql - how to use - what is needed?
mySql - how to use - what is needed? [message #34676] |
Mon, 05 December 2011 15:58 |
Wolfgang
Messages: 146 Registered: November 2011 Location: Germany
|
Experienced Member |
|
|
Hi,
I try to connect to a mysql server which is on another machine (over the local network)... so I have no mysql server installation on the machine i try to write a program with U++ - also no installtion path.
Can someone step me through the process to connect to the remote mysql server? Searched the reference and the examples but it don't work... if I include the mysql package in my project i get a Quote: | d:\ultimate++\upp\uppsrc\mysql\MySql.h(12) : fatal error C1083: Cannot open include file: 'MySql.h': No such file or directory
| error (I think because I haven't set up any paths or whatever for mysql).
best regard
Wolfgang
|
|
|
Re: mySql - how to use - what is needed? [message #34680 is a reply to message #34676] |
Mon, 05 December 2011 17:18 |
|
Hi Wolfgang,
I believe you have to have MySql client libraries installed. This step of course depends on what OS you use
Then create MySqlSession object and call its Connect() method with appropriate parameters (server name, port, database etc...). Also, did you see the docs? The code on that page is for local server, but if you look at the Connect method signature, you'll see it is equally simple to connect to remote database.
Best regards,
Honza
|
|
|
|
Re: mySql - how to use - what is needed? [message #34699 is a reply to message #34681] |
Tue, 06 December 2011 19:31 |
|
BioBytes
Messages: 307 Registered: October 2008 Location: France
|
Senior Member |
|
|
Hi Wolfgang,
I have an application used where I am working in IRL and I pass only the IP adress of the server where the MySql (version 5.5) is installed. The application has been developped with U++ and connection is done using native MySql. Hereafter is the code snippet for your information. Server identifier contains the IP (193.xxx.xxx.xx) of the Win Server. "dbrisks" is the name of the MySql database.
if(rmSession.Connect(cnxStr.At(3),cnxStr.At(4),"dbrisks",server,ScanInt(cnxStr.At(2),NULL,10))){
SQL = rmSession;
SQL *Select(SqlCountRows()).From(TBLUSERS).Where(IDENTIFIER==cnx Str.At(3));
while(SQL.Fetch())
if(SQL[0]!=0)
{
SetLogonInUse(cnxStr.At(3));
msgStatusBar<<cnxStr.At(3);
msgStatusBar<<t_(" connecté");
rmImageDisplay.setConnectionStatus(true);
rmStatusBar.Set(0,msgStatusBar,200);
rmMenuBar.Set(THISBACK1(SetMainMenu,true));
}
else Exclamation("[*A2@5 "+DeQtfLf(t_("Cet utilisateur n'existe pas !.'\n'Il faut le créer."))+"]");
}
else {
errorMessage<<t_("ERREUR SQL: ")<<'\n'<<t_("Impossible d'établir une connexion au serveur !")<<'\n'<<t_("L'application va être fermée par sécurité");
PanicMessageBox(t_("Erreur connexion"),errorMessage);
Close();
}
}
cnxStr.Clear();
}
Native connection is preferable to ODBC socket when database begin to contain a lot of records. Definitively it is better to use it in production.
if you need more information or help do not hesitate to ask .
Regards
Biobytes
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 05:28:34 CEST 2024
Total time taken to generate the page: 0.02867 seconds
|
|
|