OleDB Connection string for reading an Excel file exclusively opened by other user - oledb

Can anyone tell me OleDB Connection string to be used for just reading an Excel file exclusively opened by other user?
I tried following connection string which did not work for me:-
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Mode=Read;Extended Properties=\"Excel 8.0;HDR=YES;ReadOnly=true;\"";
This connection string throws following exception when is it opened by other user:-
The Microsoft Jet database engine cannot open the file ''. It is already opened exclusively by another user, or you need permission to view its data.
NOTEs:
Excel file is kept on share so that multiple users can open it.
Provider used:- Microsoft.Jet.OLEDB.4.0
Excel file type:- MS Excel 97-2003 Worksheet
Copying a file is NOT allowed

I would suggest that you use a background thread to retry opening a connection on an interval for some time, and when you get a connection to the excel datasource, read all your data into memory and immediately close the connection, so that other processes can access the file.

Related

Delphi iOS import/export data file using email

Assuming I have an app on iOS that generates a data file, and I would like the user the ability to import/export that file, how is that best done?
Import from email in xcode/objc:
http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app
Is this possible in Delphi? (i.e. register an ios app as file handler for a specifc file type)
(I am planning on handling export through generating an email attaching a file? I suspect this is probably possible although if anyone knows for sure, feel free to share)
It has been asked why import/export across email is useful.
Because legally EU/US law and cloud storage is difficult with personal data
You don't need any desktop computers
You can sync data between ios and android apps if user changes mobile
You are not bound to any specific cloud provider or anything similar
Quote from above article where author explains where the file path is passed to the app:
application:didFinishLaunchingWithOptions, passing the URL in the
UIApplicationLaunchOptionsURLKey, or via application:handleOpenURL.
But since I have not used Delphi for ages (for mobile), I would just like to know for sure if Delphi supports this or not before buying a new version
You can send files using email. I use the email component from D.P.F Delphi iOS Native Components to send file attachments using email. I don't see any reason why you should not be able to send your data file as long as it is not too big. Use a file extension that is unique to your app.
You could also use iTunes filesharing in order to give your users direct access to your data file. Just set the UIFileSharingEnabled key in your info.plist and store you data file inside of the documents folder. This does require a desktop PC, but it is still a very nice addition to sending backups by email.
Depending on your needs,
I would suggest looking at perhaps saving the file to a server using FTP and Indy and then on the other device you can retrieve it?
http://www.delphipages.com/forum/showthread.php?t=208397
Set the TidFTP connection parameters
Do a FTP put : // ftp.Put('testfile.txt');
Perhaps have a Database with a column that you specify a file version etc
Do a simple Get request if you want to retrive the file with the filename
or Alternatively you can save it to a blob field in a DB and have the other device read the blobfield if you don't want to do it via FTP

I am trying to open a paradox database (*.db file) with a paradox view and I get the message ("Network initialization falied.Permision denied.

I am trying to open a paradox database (*.db file) with a paradox viewer and I get the following message (Network initialization failed.Permission denied.File C:\PDOXUSRS.NET. Windows7
It's been a while so you may have to check some details.
The PDOXUSERS.net file is a lock file for the Paradox tables. When a table is opened it will place your ID in the file and table/row details.
It appears to be located in the root directory which is a bad option. Your app probably does not have write permissions there.
If the app is networked it should be in a shared location. If it is not networked it should be in a writeable folder.
The location is set in the BDE config application.
I do not have access to a BDE so cannot help any further.
In addition try to run Delphi in Administrator mode

Unable to open sql store file used in iOS application

I am using a sql based database in one of my application with Core Data framework. I have not enabled any file protection for persistent store (using NSFileProtectionKey). But I am unable to open my database file store in a directory under 'Caches' folder in Library.
Have you ever come across such an issue. Below is the image I am getting when I try to open the sql file. However, a difference from iOS 6 I could see in that folder is there are two additional files (-shm and -wal) present with the same name of the sql store file.
Could anyone please help me to find a solution to open the file.
The -shm and -wal are journal files created using write-ahead logging. You need all 3 files for a complete database. I haven't seen an encryption error falsely triggered by not obeying this rule, but it doesn't seem out of the question.
See https://developer.apple.com/library/mac/qa/qa1809/_index.html and http://asciiwwdc.com/2013/sessions/207.

How do you configure an "ASCII" transfer mode using FTP with the NSStream classes.

My App uses the NSStream classes to FTP a file from the iPhone to a server. The file is transferred but the contents are corrupted. The FTP server logs indicate that the transfer type used was "image" where the original file is of type "ASCII". I searched the KCFStreamProperty list but there seems to be no applicable property to set to control the transfer type.
I experimented with the Apple provided SimpleFTP application. It transfers up images. Changing to transfer an ASCII text file causes the same corruption issue.
Any suggestions?
Thanks

Making a copy of an ASP.NET MVC website on the same machine - catastrophy?

I wanted to run (using Cassini) two copies of my web application from the same computer - not unreasonable (or so I thought!). One using port 80, the other using port 81. So I did the following:
Stopped Cassini and SQL Express
Copy and paste of the site root folder (and renamed it)
Opened Cassini explorer and setup a new site on port 81 and pointed it to the copied location
Changed the web.config of the copied site so that the connection string used "Database=NewAlias" because SQL Express cant attach two databases with the same alias.
Started Cassini and SQL Express again
When I browsed to the NEW site, the first thing that comes up is:
Unable to open the physical file
"C:\site1\App_Data\db_log.ldf".
Operating system error 32: "32(The
process cannot access the file because
it is being used by another
process.)". Cannot create file 'C:\site2
\App_Data\db_log.LDF' because
it already exists. Change the file
path or the file name, and retry the
operation. Cannot open database
"NewAlias" requested by the login. The
login failed. Login failed for user
'NT AUTHORITY\SYSTEM'. File activation
failure. The physical file name
"C:\site1\App_Data\db_log.ldf" may be
incorrect.
Its trying to open the mdf from the OLD location (even if the web.config specifies the exact mdb path to the new location) but trying to create a log in the NEW location. Then to top it all off, drops the hint that it cannot access the ldf from the OLD location, or maybe cant log into it.
Well done Microsoft and your team once again for some truly intuitive errors! Can anyone help?
I don't think you can just copy a live database via the files. If you detach it first, then copy it, you can then reattach (with sp_detach_db) it by mounting the files as a new database.
sp_detach_db OldDb
Then copy the folder, then reattach (with sp_attach_db) the db files as a new database.
sp_attach_db NewDb, "C:\copy of site\App_Data\db_data.mdf", "C:\site1\App_Data\db_log.ldf"
Another big problem that sometimes occurs when doing this kind of thing (and did in the scenario above which is vaguely eluded to by the error message) is that although the copied MDF file is being used, its still linked to the original LDF (log file). You can run this command to get a list of which files are being used for a connected instance:
sp_helpfile
Which will give you something like this as a response:
name fileid filename filegroup size maxsize growth usage
=========================================================
db 1 C:\site2\App_Data\db.mdf PRIMARY 24192 KB Unlimited 1024 KB data only
db_log 2 C:\site1\App_Data\db_log.ldf 78080 KB 2147483648 KB 10% log only
You can see from the output that the log file is being shared with the old database which obviously will cause issues, so you can change it to point to the copied log file as follows:
ALTER DATABASE NewAlias MODIFY FILE (NAME = db_log, FILENAME='c:\site2\App_Data\db_log.ldf')

Resources