Re: [sqlite] Relative path to sqlite database

2012-02-21 Thread Taleeb Anwar
Hi,

Your exe from desktop, perhaps, crashes because it can no longer find the
resources referenced by it (and present in debug folder)

For test purpose you can try ../../db/test.db3

But this will fail on deployment. You need to programmatically find the exe
location. One of the following may help:
1. Appliaction.StartupPath
2. Application.ExecutablePath
3. System.Reflection.Assembly.GetExecutingAssembly()

Thanks and Regards
Taleeb Anwar

*Hum Mashriq Ke "Miskeenon" Ka Dil Maghrib men Ja Atka Hai!!*




On Tue, Feb 21, 2012 at 7:02 PM, Pavel Ivanov <paiva...@gmail.com> wrote:

> > Just a quick note though, when I move the .exe file to the desktop and
> double-click on it, it crashes, which suggests that the bin/debug location
> is only applicable when the application is run from within the IDE.
>
> Crash is probably because your desktop folder doesn't have db
> subdirectory where you want your database to be created. All relative
> paths are always relative to the current directory, not to the place
> where EXE file is located or where it was built.
>
>
> Pavel
>
>
> On Mon, Feb 20, 2012 at 10:11 PM, Agrawal, Manish <magra...@usf.edu>
> wrote:
> > Ah, I should have thought of that.
> >
> > When I run the application (Ctrl+F5), the path is created in bin/debug.
> This is also the folder where the .exe file is created.
> >
> > Just a quick note though, when I move the .exe file to the desktop and
> double-click on it, it crashes, which suggests that the bin/debug location
> is only applicable when the application is run from within the IDE.
> >
> > Thanks
> > Manish
> >
> > -Original Message-
> > From: sqlite-users-boun...@sqlite.org [mailto:
> sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin
> > Sent: Monday, February 20, 2012 9:51 PM
> > To: General Discussion of SQLite Database
> > Subject: Re: [sqlite] Relative path to sqlite database
> >
> >
> > On 21 Feb 2012, at 2:49am, "Agrawal, Manish" <magra...@usf.edu> wrote:
> >
> >> All the sqlite examples I see use absolute paths to the sqlite database
> in Visual Studio projects, e.g. "C:\users\test\apps\db\test.db3".
> >>
> >> How can I specify the path to the sqlite database relative to the
> application root folder, e.g. "db\test.db3"?
> >
> > Have you tried specifying a filename without a path, just to see where
> the file ends up ?
> >
> > Simon.
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> > ___
> > sqlite-users mailing list
> > sqlite-users@sqlite.org
> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Relative path to sqlite database

2012-02-21 Thread Pavel Ivanov
> Just a quick note though, when I move the .exe file to the desktop and 
> double-click on it, it crashes, which suggests that the bin/debug location is 
> only applicable when the application is run from within the IDE.

Crash is probably because your desktop folder doesn't have db
subdirectory where you want your database to be created. All relative
paths are always relative to the current directory, not to the place
where EXE file is located or where it was built.


Pavel


On Mon, Feb 20, 2012 at 10:11 PM, Agrawal, Manish <magra...@usf.edu> wrote:
> Ah, I should have thought of that.
>
> When I run the application (Ctrl+F5), the path is created in bin/debug. This 
> is also the folder where the .exe file is created.
>
> Just a quick note though, when I move the .exe file to the desktop and 
> double-click on it, it crashes, which suggests that the bin/debug location is 
> only applicable when the application is run from within the IDE.
>
> Thanks
> Manish
>
> -Original Message-
> From: sqlite-users-boun...@sqlite.org 
> [mailto:sqlite-users-boun...@sqlite.org] On Behalf Of Simon Slavin
> Sent: Monday, February 20, 2012 9:51 PM
> To: General Discussion of SQLite Database
> Subject: Re: [sqlite] Relative path to sqlite database
>
>
> On 21 Feb 2012, at 2:49am, "Agrawal, Manish" <magra...@usf.edu> wrote:
>
>> All the sqlite examples I see use absolute paths to the sqlite database in 
>> Visual Studio projects, e.g. "C:\users\test\apps\db\test.db3".
>>
>> How can I specify the path to the sqlite database relative to the 
>> application root folder, e.g. "db\test.db3"?
>
> Have you tried specifying a filename without a path, just to see where the 
> file ends up ?
>
> Simon.
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Relative path to sqlite database

2012-02-20 Thread Igor Tandetnik
Agrawal, Manish <magra...@usf.edu> wrote:
> All the sqlite examples I see use absolute paths to the sqlite database in 
> Visual Studio projects, e.g.
> "C:\users\test\apps\db\test.db3". 
> 
> How can I specify the path to the sqlite database relative to the application 
> root folder, e.g. "db\test.db3"?

You use GetModuleFileName Windows API to obtain the location of your EXE, then 
modify this location as necessary to obtain the desired absolute path to the DB 
file.
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Relative path to sqlite database

2012-02-20 Thread Agrawal, Manish
Ah, I should have thought of that.

When I run the application (Ctrl+F5), the path is created in bin/debug. This is 
also the folder where the .exe file is created.

Just a quick note though, when I move the .exe file to the desktop and 
double-click on it, it crashes, which suggests that the bin/debug location is 
only applicable when the application is run from within the IDE.

Thanks
Manish

-Original Message-
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Monday, February 20, 2012 9:51 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Relative path to sqlite database


On 21 Feb 2012, at 2:49am, "Agrawal, Manish" <magra...@usf.edu> wrote:

> All the sqlite examples I see use absolute paths to the sqlite database in 
> Visual Studio projects, e.g. "C:\users\test\apps\db\test.db3".
> 
> How can I specify the path to the sqlite database relative to the application 
> root folder, e.g. "db\test.db3"?

Have you tried specifying a filename without a path, just to see where the file 
ends up ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Relative path to sqlite database

2012-02-20 Thread Simon Slavin

On 21 Feb 2012, at 2:49am, "Agrawal, Manish" <magra...@usf.edu> wrote:

> All the sqlite examples I see use absolute paths to the sqlite database in 
> Visual Studio projects, e.g. "C:\users\test\apps\db\test.db3".
> 
> How can I specify the path to the sqlite database relative to the application 
> root folder, e.g. "db\test.db3"?

Have you tried specifying a filename without a path, just to see where the file 
ends up ?

Simon.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Relative path to sqlite database

2012-02-20 Thread Agrawal, Manish
All the sqlite examples I see use absolute paths to the sqlite database in 
Visual Studio projects, e.g. "C:\users\test\apps\db\test.db3".

How can I specify the path to the sqlite database relative to the application 
root folder, e.g. "db\test.db3"?

This is helpful when I am developing the app on different machines with 
different paths to the application root.

Thanks
Manish
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users