PDA

View Full Version : Questions about connect to remote database



stmk
11th November 2010, 09:35
i try the following code on my own computer, it can access to the database (the database on my own computer).

However, when i run this code on another computer, it cannot access to the database which is located on my computer


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);

Lesiok
11th November 2010, 10:26
Maybe firewall on Yours computer blocks MS SQL ports off.

stmk
11th November 2010, 10:59
thanks for your reply.

so, my program setting is correct?

it is possible to access to the remote database by qt programming?

tbscope
11th November 2010, 11:02
it is possible to access to the remote database by qt programming?

I already answered you that in the other post on this same forum asking the exact same question!
The problem is you, you do not understand what you're doing. I suggest you read as much as you can about the subject.