I have a Cassini application that uses Access file. Updated installer overwrites both application and database. However, application still sees the old data even after system restart. (Also copied MDB file manually to make sure it's replaced but it doesn't help.)
The only way for the application to see new MDB data is to install it to a new folder.
Connection string is standard (I think):
Connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
HttpContext.Current.Server.MapPath("App_Data\\" +
ConfigurationManager.AppSettings.Get("dbfile")) + ";Jet OLEDB:Database Password=xxxx";
Any idea what's going on and how to avoid the caching issue?
Update (to answer some questions in comments):
We can reproduce this issue only on Windows 7.
MDB is never updated by the Cassini application. We create database and send it to users. - We did make sure that file was successfully replaced by installer. Actually the same thing happens if we replace it manually.
The problem remains after Windows reboot.
Go to solution Explorer
Select mdb file
Go to properties, there is one property
Do not copy set it to Copy if newer
Set the
Cache Authorization property of connection object to false which is by default true.
http://msdn.microsoft.com/en-us/library/aa140022(v=office.10).aspx
Have you tried using the "Microsoft.ACE.OLEDB.12.0" provider? I believe it comes pre-installed with Windows 7.
The new Windows 7/Server 2008 security model presents virtualised copies of files under some conditions for each user.
Are you possibly hitting this design feature that is presenting the stale snapshots to the users after the installation completes? Is it possible the application uses different credentials to the user installing the database?
There is a description of the functionality at User Account Control Data Redirection. The recommended solution is to use a more appropriate folder for the data
Related
Hello I'm new to MVC and have been looking for a solution to my problem for the last couple days with no avail.
I've created a simple blog engine using ASP.NET MVC, after installing it on IIS on my local PC, I quickly realized I needed a database for the login service to work.
So I elected to use LocalDB on a PC that I plan to use as a server. I moved my files over to the PC and installed everything I needed. As soon as I installed SQLExpress with LocalDB and reset the site, everything was working perfectly. However, I noticed some minor typos on a section of the site that's not easily edited. Stupidly, I reinstalled the website entirely from a new build instead of just updating the view that needed correction like a smart person would do.
Now every time I attempt to login to an excising account or create a new one I simply get the error
Cannot attach the file 'C:\inetpub\wwwroot\App_Data\aspnet-FacetBlog-20161020065352.mdf' as database 'aspnet-FacetBlog-20161020065352'.
From what I've learned, It's something to do with my LocalDB instance, but fixes I've found online seem to have no effect.
Admittingly, I'm pretty naive with it comes to SQL, so hopefully the fix is simple. If I've failed to provide vital information please tell me and I'll update the question. Additionally, an explanation of what exactly went wrong would be much appreciated. Thank you for your time.
When reinstalling your site, probably you had deleted database file aspnet-FacetBlog-20161020065352.mdf in your database directory. Since deleting MDF file doesn't affect registered SQL Express instance, SQL Express thinks the database still exists and trying to connect but failed.
First, try to attach the DB using SSMS query like this:
EXEC sp_attach_db #dbname=N'aspnet-FacetBlog-20161020065352.mdf', #filename1=N'App_Data\aspnet-FacetBlog-20161020065352.mdf', #filename2=N'App_Data\aspnet-FacetBlog-20161020065352.ldf'
NB: I assumed your MDF file location stands in App_Data directory, change it to your actual database directory.
If attempt to attach by query doesn't work, try these steps:
Stop IIS/IIS Express pool if it still running.
Open a Windows Powershell instance on your server PC (install it first if doesn't exist).
Run the following command:
sqllocaldb.exe stop v11.0
sqllocaldb.exe delete v11.0
sqllocaldb.exe start v11.0
Recreate the DB instance on your project, including data connection in Server Explorer (remove then create).
Re-run the project in development machine, then copy all required files to server PC. The database instance should be (re-)generated at this time.
Restart IIS/IIS Express pool on server PC.
Additionally you may run Update-Database command from Package Manager Console to ensure database integrity.
If those solutions still won't work altogether, simply rename your database files and attach it on your project, verify the connection string then retry step (5) and (6) above.
Related problems:
EF5: Cannot attach the file ‘{0}' as database '{1}'
Cannot attach the file ".mdf" as database "aspnet-"
Delete .mdf file from app_data causes exception cannot attach the file as database
Cannot attach the file 'C:\inetpub\wwwroot\MvcApplication10\App_Data\aspnet-MvcApplication10-20130909002323.mdf' as database 'aspnet-MvcApplication10-20130909002323'
I have a legacy ASP application that I support. By support I mean that I haven't touched it since about 2005 because its just worked.
However there were a couple of data issues in the Access database that the ASP application uses. So like a fool I opened the database directly over a fileshare (using MS Access 2007), fixed the data and saved it down (in Access 2000 format).
Now the application will retrieve and display the data OK, but any updates fail with the error 3705: Operation is not allowed when the object is open. I have not changed the code in any way, the only change was the data update and database save.
I've found plenty of examples of this error, but they all relate to fairly simple issues like ensuring the recordset is closed before opening it, changing the CursorLocation enum, etc. I've tried most of these in the vain hope that something will work, but nothing has.
Any ideas how can I fix this?
Thanks.
UPDATE
I've installed a web based access database management system, and have tried to compact and repair the database. I received the error:
The Microsoft Jet database engine cannot open the file '<snip>'. It is
already opened exclusively by another user, or you need permission to view
its data. (-2147217911)
I have run the macro detailed here to determine who is logged onto the database, and just showed the admin user (which was me - while running it)
Those errors mean one thing: the database file is opened by some other process and thus is being locked.
Most likely that "web based access database management system" is the culprit, try to find how you can configure it to not lock the file, or get rid of it.
As a work around or way to verify the real problem, you can copy the .mdb file into different location and change the classic ASP connection string to check if you can update the database in its new location.
#Remou's comment above about checking the file and folder permissions was correct.
I had our server admin check the permissions, and it seems that the write access had dropped off the folder (and the files also inherit their permissions from the folder). He said that this has happened before when saving directly over the fileshare.
(accepting in lieu of an answer from #Remou)
If i use Response.Cookies["test"].Value ="Hi"; where are cookie stored in system?
Can i check Cookies["test"] value in my pc because cookies are stored in text format.
I am using VS 2008. Operating system is Windows 7.
I have tried to find in Google but not getting the exact answer. Please help to sort out this problem.
IE and Windows keeps cookies here:
%AppData%\Microsoft\Windows\Cookies
Points to the same directory as #Sohnee's does under Windows Visa and newer, but his doesn't under Windows XP and earlier, my - does.
also Temporary Internet Files can contain some cookies.
Meanwhile Firefox keeps cookies into SQLite database under profile root:
%AppData%\Mozilla\Firefox\Profiles\%FirefoxProfile%\cookies.sqlite
To read the data you need to connect to that database using any SQLite client and execute next query:
select value
from moz_cookies
where name = 'test'
I did it just now using trial SQLite Maestro. And don't forget to close all running Firefoxes before connection attempt.
Cookies are stored in the cookies folder on Windows 7. To open the cookies folder, open run in Windows and type shell:cookies. Also, as suggested above, they might be in Temporary internet files. However, I see that your cookies are not persistent. This means you are not setting any expiration on them. Therefore, they won't be stored on your machine and they will only be part of the browser's memory.
C:\Users\<user_name>\AppData\Local\Google\Chrome\User Data\Default
Also note, "Local" is a hidden folder.
For Windows :
C:\Users\Your User Name\AppData\Local\Google\Chrome\User
Data\Default.
For Mac:
~Library/Application\ Support/Google/Chrome/Default/Cookies
You can use SQLite Browser for access it .
Your cookies are stored in your user folder:
%userprofile%\AppData\Roaming\Microsoft\Windows\Cookies
You will need to "show" hidden / system files to see them.
On Windows 10, I press Win+R and type shell:Cookies to open the cookies folder.
it's a hidden folder, the path is
C:\Users\admin\AppData\Local\Microsoft\Windows\INetCookies
I have an ASP.NET server that provides its client as an MSI download (similar to CCNet/CCTray).
There can be more than a single server (for example, for dev/testing/production, but there may be different production instances).
So client has to know server URL. I can not ask users for URL because it does not really make much sense for them, they do not know of any other servers anyway. So the MSI should have the server URL included.
Now, I can pre-build different versions of MSI for different environments (since there are already distinct build steps for these dev/test anyway), but this does not solve a question of several productions where the product is already built.
So I think server should modify the MSI and add the correct URL before serving it. Is it possible without rebuilding the msi? What is the easiest way to achieve this?
Basically an MSI file is just a database, using the Windows Installer API you can run arbitrary SQL on this database... for example:
Dim installer, database, view, result
Set installer = CreateObject("WindowsInstaller.Installer")
Set database = installer.OpenDatabase ("setup.msi", 1)
Set view = database.OpenView ("INSERT INTO Property (Property, Value) VALUES ('URLPROPERTY', 'http://some.server/blah/service')")
view.Execute
database.Commit
Set database = nothing
Just use this script in a post-build or pre-download process and you'll be sorted :)
For more information and additional (better) sample scripts, refer to the Windows SDK
I don't know of a way to modify the MSI itself, but you can have the server write the url to a known file on the client and have the MSI project read in that file (and delete it). That way you can have one MSI build for all servers.
Modifying MSI file on web server before serving it is not a good idea. What if someone requests the file while you are still updating it?
You are better off modifying your build process to produce a set of MSI files corresponding to production websites. Each website would have its own custom MSI file.
Since the answers did not really cover the problem, I posted this on ASP.Net and completly rephrased it. I will post the edited question here:
I have been using the attachDB connection string and I usually deploy to IIS. The site works fine, however, I made some changes to the database and the newest version would not copy as it said file in use.
I opened up SQL management studio and saw that it was mounted so I did a dettach.
I was then able to copy the new version without problem, however, when I next run the site, I get:
Unable to open the physical file "C:\inetpub\wwwroot\vs\App_Data\aspnetdb.mdf". Operating system error 5: "5(failed to retrieve text for this error. Reason: 15105)".
An attempt to attach an auto-named database for file C:\inetpub\wwwroot\vs\App_Data\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
And, if I try to access .Net users or the other few options within IIS Manager, I get the following error:
.NET Users
There was an error while performing this operation.
Details:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)
OK
I have tried recycling the application pool, restarting the SQL instance and even restarting the computer.
Nothing helps and I cannot figure out what is wrong... Where does it remember where previous databases are connected and why doesn't it automatically reattach the database?... Someone said that they auto detach after 2 1/2 hours, however I waited 5 hours when a database wasn't in use and SQL Manager showed it was still attached.
When I manually reattach the database, everything works fine.
When you ask a database to be attached on-the-fly to a SQL Express instance using the AttachDBFileName connections string the application will not connect to the SQL Expres sinstance at all, but instead it will connect to a child instance, which is an new instance created specificaly for the user requesting the attach operation. See SQL Server 2005 Express Edition User Instances. This child instance will attach the database and will continue to run for up two one hour, after which it will shut itself down.
When you try to connect from 'enterprise manager' you will not be able to connect to the child instance (is realy complicated to connect explicitly to one, so you cannot accidentaly do it), you are connecting to the parent instance and messing with the database.
To summarize, either stick with the RANU model and use AttachDBFileName, or use a normal database operations mode and manage the database from the SSMS. Don't mix the two.
Are you certain there isn't already a database with the same name attached to the SQL Express instance you are pointing your site at?
Also, does the identity the site is running under when it attempts to attach the database have admin rights in SQL Express? If not, this command won't work (I'm not sure what error it gives in that situation, but "Access Denied" would sound reasonable).
The page "SQL Server 2005 Express Edition User Instances" seems to give a good overview of the issues and workarounds.
Edit to add
Could this be the issue:
An error will be generated if a log file exists in the same directory as the data file and the 'database' keyword is used when attaching the primary data file. In this case, remove the log file. Once the database is attached, a new log file will be automatically generated based on the physical path.
Taken from the documentation for SqlConnectionStringBuilder.AttachDBFileName Property
You'll need to delete the log file before you can re-attach the database through this method.