PDA

View Full Version : can qt access remote database?



stmk
11th November 2010, 08:17
i try the following code on my own computer, it can access to the database (the database is on my own computer).
However, when i run this code on another computer, it cannot access to the database


xxx.xxx.xxx.xx is the ip address of my own computer (which launch the MSSQL)

i try whole days, but still no idea :/
can anyone give me some suggestions?
Thank you very much!


QString serverName = "xxx.xxx.xxx.xx\\SQLEXPRESS";
QString dbName = "myDB";
QString dbID = "sa";
QString dbPW = "abcd";

QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
QString dsn = QString("DRIVER={SQL Server Native Client 10.0};SERVER=%1;DATABASE=%2;UID=%3;PWD=%4;").arg(serverName).arg(dbName).arg(dbID).arg(dbPW);

db.setDatabaseName(dsn);

tbscope
11th November 2010, 08:20
Qt uses the actual database software as backends.
As long as the database you use supports it, Qt will support it too.

Of course, you need to make sure that the computer containing the database is accessible. Are the ports open? Is a server running? etc...

stmk
11th November 2010, 08:33
i sure that the database is accessible since it can connect and retreive the data from the database on my own computer.
but it doesn't work when the remote computer wants to access my database (MSSQL)

Talei
11th November 2010, 17:16
And that's because You didn't allow access from the network (You can access from localhost but not from i.e. 192,x ).
Read this (http://www.sevenforums.com/system-security/58817-remote-access-sql-server-express-2008-windows-7-a.html) it should help.

stmk
12th November 2010, 02:41
I solved the problem by myself now.

Since the client side do not install SQL Server Native Client 10.0, so they can't connect to the server's database

thanks all.

amitkumarmannur
5th November 2012, 17:52
HI Please mail me solution please As soon as possible.

I want to connect my mobile to my system database .

how to do so... call me +91-9686911900 or amitkumarmannur@gmail.com
I want to wirte a program which i can deploy in mobile