PDA

View Full Version : Connection with MySql



vishva
31st July 2006, 07:54
Hello friends,

I am developing small database application with database MySql , actually database installed in remote system. I want to access database file example test.db from that remote system. I wrote the following lines in my application , but receive error .
i.e can’t create TCP/IP socket (10093)QMYSQL:unable to connect.


QSqlDatabase db1=QSqlDatabase::addDatabase("QMYSQL");
db1.setHostName(“ Remote system ip address “);
db1.setDatabaseName("test.db");
db1.setUserName("root");
db1.setPassword(NULL);

if(db1.open())
QMessageBox::information(0,"DB","Access");
else
QMessageBox::warning(0,"DB","Not open");
QSqlError err=db1.lastError();
QString str=err.text();

How to make connection with database ?
tool: Qt 4.1
OS :Windows XP
IDE : VC++.NET

wysota
31st July 2006, 09:46
This looks more like a system error. What happens if you try to connect to that database using mysql console?

vishva
31st July 2006, 11:58
This looks more like a system error. What happens if you try to connect to that database using mysql console?


hi,
I was sloved that problem. Just add few codes in main cpp program. such as
Inc files:
#include <winsock.h> and create object for WSADATA and initialize startup module WSAStartup(0x0202, &wsadata) .

Thanks for Your valuable reply.