When I try to connect to a database that was previously opening with a SQL connection I get a "File in Use" error. Process Explorer tells me that sqlservr is still holding the file. Any ideas on how to get sql to release the file from within the vb.net 2010 code?
After you closed the connection you must call
SqlConnection.ClearPool
or
SqlConnection.ClearAllPools
in order to release the files from the SqlServer.
Which file is this? Is it a file that's normally internally managed by the SQL server? If so, then you'll probably have to ask the SQL server to shut itself down before you can open the file.
You may also want to consider your reasons for wanting to access such a file. If it's for backup purposes, you are almost always better off using the services of your database to perform backups, instead of trying to do it yourself.
Related
I created an Access front end for a SQL DB on my PC for use throughout my company. I am using a file ODBC connection and putting both the ODBC file and the Access file on a shared network drive.
When I load the access file, for some reason it seems to default to using my windows login credentials and pulls in the data perfectly. When a user attempts to open the file, they receive an error message saying "ODBC --call failed.". I can open the Linked Table Manager for them and check 'ask for new location' then specify the ODBC file and it all works fine...however it doesn't seem to save anything. I get the error each time someone other then myself opens this file.
Any idea what could be wrong? I am not an Access guy by trade, it just seems to be the tool we need for the moment.
--EDIT: For Clarification I am using a file ODBC connection
--Edit 2--
Riddle me this. So I have been troubleshooting this issue and I came across something interesting. I was logged in as one of my users and did the following:
Create a new access file that references a file ODBC connection on the desktop.
Create 3-4 linked tables in the access file, using the ODBC file on the desktop.
Save and close the access file.
Re-Open said file.... and I get an ODBC connection error! Right after everything was fine in a fresh file!
Anyone ever experience this?
i assume you didn't install the ODBC correctly on each users PC.
you should create the ODBC-definition. You can create the relevant statements directly in the registry, see this branch
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI
if you give the same name as on your developer machine, then it works. that's how i do it with my client applications that i develop on my machine and then install it at client site
After beating my head against the wall having this same issue, I finally discovered I had a checkbox on the Access form that defaulted to NULL. Since I put the backend into SQL, the checkbox fields cannot be NULL but the 'ODBC Call Failed' message did not help. I finally tried to add a record directly on the table via Access and it gave more information. I set all the checkboxes to default to zero and it resolved the problem!
Well, I was able to narrow the issue a bit. Access for some reason keeps trying to use Windows Credentials instead of the username in my ODBC file. I can't find a way around it, but I was able to resolve the issue by creating logins on my SQL Server for the windows users that need access.
I am not incredibly happy about needing to manage more logins, but that's what i did to resolve this issue.
I don't mean to resurrect the dead, but I had this same error stem from a different issue.
I was using an ODBC connection. When running the file using the 'Design' run button it worked fine. When I tried using the Navigation Pane and double clicking on it, the error would happen.
The structure of my query was the problem; I was porting a SQL server query over and the single quote ' parameter passing was not well received in Access. Changing these over to double quotes " made it work.
I just started using SSIS and am trying to upload an Excel file. When I get to the Excel Connection Manager and use the variable pointing to the file path of it's location, I get the following error:
"An OLE DB record is available. Source: "Microsoft JET Database Engine" HRresult: 0x80004005 Description: "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."
The SQL Server and SSIS software are brand new. The destination table is already set up. What could I try to fix the issue?
Looks like there is a lock on the file (on the server, right-click my computer, manager, system tools, shared folders, open files).
OR look for Excel Version in Excel connection manager, choose MS excel 97-2003. I assume you are using new version
Make sure you don't have the spreadsheet open in Excel, it will put a lock on the file and prevent it from being opened by SSIS.
sometimes if excel didn't close properly it might leave an instance in memory locking your file. You may need to check it with Task Manager and kill the excel instances manually.
Close out of Server Manager or Visual Studio. It will release the file.
I've created a new database using Microsoft SQL Server Management Studio, and now I want to interact with it through LabVIEW. I already have several VIs to interact with a previous database, using the database connectivity tool kit. This database was created by someone who has since left the project and I can't find it in anything but LabVIEW.
I'm quite experienced with LabVIEW, but completely new to and bewildered by databases.
Thank you in advance.
The first Connectivity Toolkit VI called should be Open Connection.
The existing code (VI) will either use a file or a string as an input.
If the input is a string, then you will need to create a new connection string compatible with your server. You can find common SQL Server strings at https://www.connectionstrings.com/sql-server-2008/
If the input is a file name, you can copy the .UDL file that is referenced and then modify the copied file by opening it (double click) and then select the OLE DB Provider for SQL Server and then set the connection options to point to your server, database etc. and then test the connection.
Basically the workflow you have to go through is the following:
Open connection
Execute your query
Fetch data (if needed)
Close connection
If you search for "Database" in the NI Example Finder shipped with Labview you will find a few good starting points.
In particular give a look to Database Connection.vi and Database Fetching.vi.
If you plan to use transactions try also Database Transaction.vi.
I found that the solution to my problem was to create a .udl file and use that as the file path for opening the database connection.
Here's the address that taught me how to do this:
http://msdn.microsoft.com/en-us/library/e38h511e(v=vs.71).aspx
Thank you to everyone who submitted answers, they certainly helped point me in the right direction.
I've read through a couple of previous similar questions and none seem to provide a fix.
so i ask again.
I'm using Visual Studio and am trying to connect to a DB in Server Explorer. Regardless of what database i try to connect to it gives a "Given Key not Present in the Dictionary" error.
i have tried with SQL CE and SQL Express 2008 databases and each give the same issue.
I can connect quite easily with SQL Management Studio Express so i believe the Databases are the same.
Thanks in Advance.
after a lot of time searching for the answer to this i found the solution here
this is not really a workaround but in fact a SOLUTION, how to get rid of the error, in case you have missed to remove all connections before removing the provider:
edit C:\Users...\AppData\Roaming\Microsoft\VisualStudio\10.0\ServerExplorer\DefaultView.SEView and remove the connection with the wrong Provider manually. If you do not know which of the provider is failing, simply delete the file :)
If this won't help try deleting also C:\Users...\AppData\Local\Microsoft\VisualStudio\10.0
PS: you have to quit all instances of visual studios first or the files will be re-created from memory ..
The second part only worked for me , deleting the whole folder.
I had recently installed the MySQL Connector, and had multiple instances of Visual Studio open. After shutting them all down, I was able to add a connection to the Server Explorer.
Adding to what BastanteCaro said, I had open the DefaultView.SEView file in case I needed to go down that path. When I shut everything down and started up a new instance of Visual Studio, Notepad++ reported that the file had changed. So either there was an uncommitted change to the file or some sort of cleanup/addition was made on startup.
My DBA's are saying my foxpro application or .DBC (Database container) are hitting SQL server but searching all the code can't find the SQL call (FMTONLY ON/OFF).
This is the SQL command being sent:
FMTONLY ON/OFF
Getting called 16260 times every few minuets?
Any ideas how to find this or what could be causing it, maybe my DBC file?
If you can't find it embedded in the .DBC, but not entirely sure its NOT in there, you can use a VFP tool to dump its contents to a .prg file... GENDBC which is in your installation folder of {VFP}\Tools\GenDBC\GenDBC.prg
Open your database, then run that program, it will cycle through all the tables, indexes, relations, connections, etc and generate the code corresponding to everything in it... You could then look at the output .prg file and see if something in there might be triggering what you can't see otherwise.