Source language: Translate to:

NeoBookDBPro - Embedded database

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

NeoBookDBPro - Embedded database

Postby Skarabäus » Thu Jan 17, 2008 3:12 am

Dear neobookers,

1.
I have following situation:

- data fields were made in a pub which are related on a .mdb database
- database and pub are stored in the same place on the local hard disk

What have i done?
- I embedded de .mdb database
- I replaced the path that relates to the .mdb database in the code by [Embedded] as follows

:DatabaseOpen
If "[DBStatus]" "<>" "Open"

FileExists "[Embedded]ab.mdb" "[Result]"
If "[Result]" "=" "True"
dbpOpenAccessDatabase "Database" "[Embedded]ab.mdb" ""
dbpOpenTable "Database" "companies" "DataBaseUpdate"
Else
dbpCreateAccessDatabase "[Embedded]ab.mdb" "Encrypted=Yes"
dbpOpenAccessDatabase "Database" "[Embedded]ab.mdb" ""
dbpCreateTable "Database" "companies" "NAME String(254)dbpCreateIndex "Database" "companies" "NAME" "idxName" "PrimaryIndex=No;Unique=No"
dbpOpenTable "Database" "companies" "DataBaseUpdate"
EndIf
dbpOpenTable "Database" "companies" ""
dbpOpenTable "Database" "companies" ""
SetVar "[DBStatus]" "Open"
EndIf
Return

What is the result?
- FileExists, dbpOpenAccessDatabase, dbpCreateAccessDatabase seems to accept this
- The problem seems that the connection to the table "companies" get lost because i get a lot of exclamation marks when i call up the input window like dbpOpenTable

2.
If there would be no solution for this, what can i do?
My aim is to compile the pub to a standalone .exe

Many thanks for the replies.

Skarabäus
Skarabäus
User avatar
Skarabäus
 
Posts: 37
Joined: Mon May 15, 2006 4:31 am
Location: Germany, Ostfildern

Postby Gaev » Thu Jan 17, 2008 6:34 am

Skarabäus:

[Embedded] files are READ ONLY ... you can not update the content of such files at run time ... same thing if you try doing a FileWrite action on an [Embedded]abc.txt file.

dbpCreateAccessDatabase seems to accept this
... seems is the operative word here ... perhaps because, at this stage the data is still in memory ... but at some time before the database is Closed, the content will have to be written to file ... and how would Access/SQL drivers know about the internal structure of the [Embedded] file inside an .exe file ? ... and image what would happen if this .exe file was updated (expanded/shrunk) while Windows was using other parts of the same file to run your application ?

If there would be no solution for this, what can i do?
My aim is to compile the pub to a standalone .exe
Do you know of any other technology (under Windows) that does this ?

The closest one can get to this ... is to have your application exe file stored inside a Table (e.g. called myExe) within the ab.mdb database ... as the content of a Picture Field ... then use a (stub) program ... to extract the .exe file to the [TempDir] folder ... and Run this extracted .exe

If required, the .exe can be designed so that before it Exits, it calls the same (stub) program with a command line parameter ... which would then erase the extracted application .exe

Note, the above suggestion has not been tried in practice ... and could come up against "a wall of security related issues"
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Skarabäus » Thu Jan 17, 2008 7:10 am

Gaev:

I summarize, the best way to manage it is as follows:

I must carry the database outside of the created .exe.
If the database is carried outside it should be a database format that computers of users recognize and accept.
In this case it should be best to use databases in .dbf instead of .mdb format.
Furthermore it is better to compile the pub to a setup program instead of a standalone. So a folder can be laid out on the local hard disk of the users, and the program itself can interact with this database without problems.

Gaev, have I understood it correctly?
Skarabäus
User avatar
Skarabäus
 
Posts: 37
Joined: Mon May 15, 2006 4:31 am
Location: Germany, Ostfildern

Postby Gaev » Thu Jan 17, 2008 8:23 am

Skarabäus:
have I understood it correctly?

I must carry the database outside of the created .exe.
Not required ... just have to have the database "extracted" on the user's local disk before you start to use it.

If the database is carried outside it should be a database format that computers of users recognize and accept.
Not necessarily ... depends on your requirements ...

- if you want the contents to be readable/writeable by other programs, it would be desirable/necessary to use a file format whose drivers are widely available

- if you want to provide uber-protection of your data, you can go ahead and create your own propretary file/database structure

In this case it should be best to use databases in .dbf instead of .mdb format.
No ...

- if you develop with NeoBook, it doesn't matter ... because an application/exe compiled using NeoBook does not need any external programs/libraries/drivers to read/write either of these database files on another computer ... just the .exe and the database file

- but now that NeoBookDBPro is available, I would use Access (.mdb) over dBase (.dbf/.dbt) any time ... remember that an .mdb file is like multiple .dbf/.dbt files all zipped into one big file (as far as windows is concerned) ... so it becomes a lot easier to manage ... both for you and your user

Furthermore it is better to compile the pub to a setup program instead of a standalone. So a folder can be laid out on the local hard disk of the users, and the program itself can interact with this database without problems.
By "compile the pub to a setup program" I trust you mean "package the compiled exe and its database into some kind of self-extracting install program" ... which would be one choice ... but this may not be necessary ... you can still "Embed" the associated database inside your pub/exe ... you just have to ExtractFile the database file at "Startup" time to the user's local disk ... into the [PubDir] or [MyDocuments] folder ... after you check that it does not already exist there (from the previous time) ... you can then go ahead and do something like ...
Code: Select all
dbpOpenAccessDatabase "Database" "[PubDir]ab.mdb" ""
dbpOpenTable "Database" "companies" "DataBaseUpdate"
etc. etc.
... without any problems ... just can't put the Genie back into the bottle :-)
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Skarabäus » Thu Jan 17, 2008 8:35 am

Gaev:

Thank you very much for your help.

Now i have enough food to find a solution.
If I should need nevertheless further help to this topic, i would be very pleased about your support.

Again many thanks.
Skarabäus
User avatar
Skarabäus
 
Posts: 37
Joined: Mon May 15, 2006 4:31 am
Location: Germany, Ostfildern

Postby Skarabäus » Fri Jan 18, 2008 4:48 am

Dear Gaev,
dear neobookers

Thank you very much again.

With your suggestions and my trials and errors i can now extract the .mdb file on the local drive of a user and the .exe works fine.

However, I have stated the following:
- .mdb file is not encrypted
- .mdb file can be opened during runtime of .exe file
- .mdb file will not be hidden during runtime and not removed after publication terminates

For this, now i open a new topic.
Skarabäus
User avatar
Skarabäus
 
Posts: 37
Joined: Mon May 15, 2006 4:31 am
Location: Germany, Ostfildern

Postby dpayer » Fri Sep 28, 2012 8:02 am

Skarabäus wrote:Dear Gaev,
dear neobookers

Thank you very much again.

With your suggestions and my trials and errors i can now extract the .mdb file on the local drive of a user and the .exe works fine.

However, I have stated the following:
- .mdb file is not encrypted
- .mdb file can be opened during runtime of .exe file
- .mdb file will not be hidden during runtime and not removed after publication terminates

For this, now i open a new topic.


Your question appears to be: how can I have a database that is only available to my application and cannot be read or used by another?

Some ideas:
1) put your database online and protect with some form of authentication (a bit complicated)
2) alter your database file to be unreadable after each use of the application (David de Argentina has a plugin to alter binary files) but this may slow things down
3) hide the file by changing its attributes and put it in a hidden subfolder and have a subroutine on exit to delete the file.

David P.
User avatar
dpayer
 
Posts: 1384
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 1 guest