Problem: Connect with SQL to windows SQL server 2008 .mdf
-
you should pass an ODBC connection string by setDatabaseName.
take a look at "www.connectionstrings.com":http://www.connectionstrings.com and find a right ODBC connection string for your database.
Probably you have to had SQL Server installed on your PC and mdf ldf should be attached. -
Thanks for reply,
I searched for my connection string en edited my code
@void MainWindow::on_pushButton_clicked()
{
db = QSqlDatabase::addDatabase("QODBC");
db.setDatabaseName("Driver={SQL Server Native Client 10.0};Server=.\SQLExpress;AttachDbFilename=/home/MlovesT/QT-programmas/SQL/dbIT_Store.mdf;Database=db; Trusted_Connection=Yes");
db.open();
ui->lineEdit_2->setText(QString(query.exec("SELECT Omschrijving FROM tblProducten WHERE ProductID = '1'")));
db.close();}
@
But still got the same error.
And the ldf and mdf file are 2 files from a friends computer (from windows SQL server 2008), i need these files for our project.
He made these files on a windows PC, while im working on a Linux.I still don't really know what's wrong.
Thanks in advance
Greetings Tristan
-
Thanks for reply
Why doesn't it work on an UNIX system? I have 3 drivers installed for ODBC on my Linux system: qt-sql-odbc, UNIXodbc and UNIXodbc-devel. So why can't i connect to an mdf database file with QT in Linux? I have no errors in QT that my drivers aren't installed.
My attached file is: /home/MlovesT/QT-programmas/SQL/dbIT_Store
But i want to connect to a local file, this has to be possible in some way? or am i wrong?
Greetings,
Tristan -
Okay, you helped very much because I now know I cant configure and OBCD server for a symbian device. I wanted to connect a symbian device to an MS server via SQL for our project, so i first tested OBCD on a desktop application. but now i guess that's impossible.
So we are solving the problem in another way... We have a visual basic program which can connect to an windows SQL server very well. So we are gonna run this visual basics program on the same server (same Ip) as the SQL server. Then the smartphones are going to connect to this Visual basic - server program trough TCP/IP, by sending an Query string. The visual basics server then sends a Query with the Query string from the smartphone, to the local MS SQL server etc etc....
So thanks for helping!
Greetings,
Tristan