Application path did not work!
-
How exactly is it failing? Segfault, empty string?
-
stupid problem!!
it is return me true path (directory of execution file!). but not working!this is address of my db file.
are there any way for get db address near exe file?
my db address: data/257115.db that data folder is near exe file. -
The [[doc:QDir]] class has many methods to do manipulation of file paths.
-
What is the value of path and what do you expect?
Any qDebug() output? -
the output is right but not working!
you know.
i'm using sqlite that db file is near my exe file in folder "data"in my OS (Win 7 64bits) working write,but my application in other os(other windows in other computer)
cant access to db file! -
[quote author="abbas farahmand" date="1327920166"]the output is right but not working!
you know. [/quote]
No, we don't know. What are you seeing exactly? What did you expect? And what is not working?
[quote]
i'm using sqlite that db file is near my exe file in folder "data"in my OS (Win 7 64bits) working write,but my application in other os(other windows in other computer)
cant access to db file![/quote]But you are not showing us the relevant code for that, so how can we help you?
-
Maybe permissions are wrong on that other system? Also, you should probably add ".db" to the path.
-
:D
ok.
@
QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
mydb.setDatabaseName(QCoreApplication::applicationDirPath() + "/data/27115");
mydb.open();
if (mydb.open())
{
goview();
}
mydb.close();
}@
27115 is my db file and don't has extension
i'm using this code and working right in my laptop now.but in other pc.... cant find db file! -
Although that is not related, you should not be invoking "mydb.open()" twice. You can delete one in line 3.
-
[quote author="sierdzio" date="1327921175"]Although that is not related, you should not be invoking "mydb.open()" twice. You can delete one in line 3.[/quote]
No.this problem was not for this!
thanks -
What output do you get if you change your code to:
@
QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
QString databasePath = QCoreApplication::applicationDirPath() + "/data/27115";
qDebug() << "database location:" << databasePath;
mydb.setDatabaseName(databasePath);
mydb.open();
if (mydb.open())
{
goview();
}
mydb.close();
}
@Please also tell us what output you expected there.
-
[quote author="Andre" date="1327922300"]What output do you get if you change your code to:
@
QSqlDatabase mydb = QSqlDatabase::addDatabase("QSQLITE");
QString databasePath = QCoreApplication::applicationDirPath() + "/data/27115";
qDebug() << "database location:" << databasePath;
mydb.setDatabaseName(databasePath);
mydb.open();
if (mydb.open())
{
goview();
}
mydb.close();
}
@Please also tell us what output you expected there.[/quote]
the output is : @
database location:C:/Users/MR.Farahmand/Desktop/parsipedia-001-beta-build-desktop/debug/data/27115
@
the database address is true but....!! -
but what exactly?
You are sure that the database file really exists at that precise location? -
but cant find db file
i'm copy db file to C:/ location and its working!
but in
@
mydb.setDatabaseName(QCoreApplication::applicationDirPath() + "/data/27115");
@
cant connect to db.(maybe cant find db file!) -
Can you please write complete sentences? And can you please stop filling in nonsense like "you know" - no, we don't. None of us has a crystal ball here and none of us knows what you're doing and what you're expecting.
There is nothing like "database address is true" - that's a nonsens statement. We're talking about a path here. That can be valid or not. It can exist or not. But it can neither be true nor false. A bit more precision, please.
Do you work with an existing database or do you create it at runtime?
For the former:
Does that path exist?
Is it really a file and not a directory?
Can your read it?
Is it an sqlite database file?For the latter:
Does your data subdirectory exist?
If not: create it! Sqlite will not do this for you! -
thanks
I fixed it with other ways. -
I don't believe what I see. This post is useless and it was a waste of time for all who participated...
Seba84
-
Hi to all
I'm so sorry for times that you used for this post
that's problem was not for db file path
web must copy sqldrivers folder to output folder (debug folder neer exe file).
[quote author="Seba84" date="1328030127"]I don't believe what I see. This post is useless and it was
a waste of time for all who participated...Seba84[/quote]
any post can't be useless!!
maybe some people have this problem exactly !thanks all
-
[quote author="abbas farahmand" date="1328272043"]
maybe some people have this problem exactly![/quote]Well, you never posted a solution.
You described your problem, we plead for additional information and then
[quote author="abbas farahmand" date="1328272043"]
I fixed it with other ways.
[/quote]So if you want this thread to have any valuable information for others you better hand in what actually solved your problem - what you now did.