Access 2010 - Connecting LocalDB to Microsoft Access via DSN - sql

I have created a local db and I want to connect some tables to Microsoft Access. I'm doing this via Microsoft Access's "Link to the data source by creating a linked table" feature" and in order to do that I need to create a DSN. However I'm getting an error where it says
"Server does not exist or access denied"
At the moment I'm trying to create a new DSN and i'm stuck during the below step which I need to specify my server. I've tried two different server names and they both don't work.
Note: It's definitely not an access denied issue because I've tested the login myself and they all work fine.
Can someone please tell me what I'm doing wrong or is it not possible to link Access to a local db.

Resolution
When choosing a driver for the new data source, use either the ODBC Driver...for SQL Server or the SQL Server Native Client. (note: I am also able to get the "SQL Server" driver to work, but only by specifying the named pipe address of the instance in the next step/image where specifying the SQL Server to connect to.)
The SQL Server to connect to in the "Create a New Data Source to SQL Server" should be "(LocalDB)\instancename"; in this case "(LocalDB)\MSSQLLocalDB"
Caveats
As the LocalDB name itself implies, connections to it can only be
made from the local machine. If you need to access an instance on a
different machine, and need a free solution, you should use SQL
Server Express.
These results were obtained using Access 2016. My
experience with other software indicates it should work with Access
2010 as well, but I did not test that. If you have trouble, try using
the named pipe address for the instance instead of the
"(localdb)\MSSQLLocalDB" moniker in the image above.
Results
Here are the results of testing the connection, then adding links to two tables in the master database

Instead of using a LocalDB I used SQLExpress which worked fine.

Related

Unable to connect to a migrated Access database on SQL Server as another user: SQL server Error 4060

I have an Access DB that I migrated to SQL server recently. The SQL server is on a Windows server. Now I can work normally with the SQL database but when others log into the same windows server with their credentials they are not able to access the database. As soon as they open Access frontend they get an error saying failed connection. Now I created an ODBC connection string(File DNS) and gave it to the other users in the network but they still are not able to connect to the database. They get an error stating "SQL server connection failed. The server rejected the connection: Access to the selected database has been denied". Can someone please help me to solve this issue so that multiple users can connect to the SQL DB without any issues? Thanks
Hard to know with the limited information. Are you using windows authentication to sql server, or are you using SQL logons? Either should work fine. The other issue to watch out for is what sql driver did you use to link with?
If you link say using the native 17 ODBC driver, then that is not installed on workstations by default - you have to download and install that driver.
Or, maybe you linked using the long time "legacy" sql driver - that is by default installed on all workstations.
So, it not clear if you using SQL logons, or using Windows authentication for the connection to the database????
If your using windows authentication, then all those other users will require permissions to be granted to the database.
If you using a SQL logon, then that logon would have been saved when you link the table(s), and again it should work for all users. Its quite common to create ONE logon on SQL server, link using that logon, and thus all users will be connecting to the database using the one same logon id/password.
And, if you linked using a FILE dsn, then zero configeration should be required, since access converts FILE dsn's into what are called dsn-less connections. (the origonal file is not required anymore once you link - you can even delete that FILE dsn, and it will still work).
So, FILE dsn is the best choice, since that dsn is NOT required to be setup on each workstation.
And if you using sql logon's, then make sure you checked the box to remember the password during linking of the tables. That is this check box:
And note during a re-link the above box does not appear - only on first time linking of table(s).

Connecting to a SQL Server Express 2012 from another computer using MS Access

I have set up an instance of SQL Server Express 2012 on a computer. On this computer I use MS Access as the client to access the data stored on the SQL Server Express. When I open MS Access and click on an object it then prompts me for the SQL Server username and password (I set up a SQL Server Native 11.0 Driver). This works fine. The goal is to put the file on others computers so they can access the data on our SQL Server. I also have enabled the TCP/IP protocols to allow remote connections as well as the Firewall settings that are necessary. However, when I place the file on another computer, it returns SQL Server Error 53.The strange thing is that I have another computer that I tested this on and it works perfectly fine.
My assumption is that I am missing software on the client computer. What software must be present on the client computers so it will be able to access my SQL Server Express on the "server computer"?
Please let me know if you have any questions, at this point I am stumped.
If you're using ODBC, then on the 2nd computer you need to
Start->Control Panel->Data Sources (ODBC)
Select System DSN tab
Click Add...
Select SQL Server Native Client
Give it the same name as the name on the working computer
Select the server to connect to etc.
and you should be OK

Connect LINQPad to remote SQL Server

Disclaimer: I understand the question is very basic, but I could not find the answer in Google or here, and can not do it myself with guessed configuration.
I want to get started with LINQPad and I have a SQL Server 2005 installed on different machine in the same domain. But I can not connect to that server from LINQPad.
Here is the screenshot:
What do I put as a Server string?
Many thanks in advance!
Update 1: SERVERNAME\MSSQLSERVER does make a difference. Instead of Error
26 (Can not find server instance)
I get error
25 (Connection string is not correct)
I have tried 2 different SQL Servers: SQL 2005 on production server and Sql Server 2008 R2 on local machine, I have tried windows authentication and SQL authentication. And it makes no difference.
But I can connect to both server (2005 and 2008) with MS SQL Server Management Studio with Windows and SQL server authentication. And it's not SQL Server permission issue - I have tried SA user to connect. It works with sqlservermanagementstudio, but not with LINQPad.
Any advice? Is there a setting on SQL Server I need to change?
Update 2: I found the solution to the problem.
Into Server field I had to put SERVERNAME\ without specifying SQLEXPRESS or MSSQLSERVER.
Not very intuitive =(
I found the solution to the problem.
Into Server field I had to put "SERVERNAME\" without any SQLEXPRESS or MSSQLSERVER.
Also as pointed out by #sgmoore, I could just type "LOCALHOST" or "SERVERNAME" and it connected.
Apparently this is SQL Server feature/bug, nothing to do with LINQPad.
UPD You can also use "." to denote "localhost"
You have to know the name of the computer you want and the name of the SQL-Server instance. For example, I have a computer named REB602, and, to use SQLEXPRESS on it (the SQL-Server instance that comes pre-installed with many versions of Visual Studio), then the string I type in is either REB602\SQLEXPRESS or .\SQLEXPRESS. The format is basically <computer-name> \ <instance-name>
I think the default instance-name for the full SQL-Server product is MSSQLSERVER, so if you don't know the name of the instance on the target computer, you can try that.
NOTE: it can take several tries to get a connection, because of the timeouts. I don't know if LinqPad lets you change the timeout -- I didn't see a way. When testing out my answer for you on computer REB602 this morning, I did "Test Connection" at the bottom of the LinqPad dialog box, got success, but the connection still timed out. I had to bring up SSMS (SQL-Server Management Studio, the IDE for SQL Server) to "warm up" my instance of SQLEXPRESS. After that, LinqPad worked like a dream. Don't give up on the first try :)

Connecting to SQL Server 2008 Express from VB 2008 Express

I'm using VB 2008 Express for our College Project. I'm also running SQL Server 2008 Express and have installed SQL Server Management Studio and used it to create my database.
Both software have been installed and running locally. I'm trying to connect to the database from VB 2008 Express. Database connection wizard have 3 options:
connecting to Access db
connecting to SQL Server 3.5 compact db and
connecting to SQL Server db file.
There are no problems connecting to the first two but when I try to connect to my SQL server DB file (.mdf) it throws the following error ("Unable to open the physical file .... Operating system error 32:(failed to retrieve text for this error. reason:1815.......an attempt to attach an auto-named database for file ...... .mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share")
I appreciate if anyone who had the same experience and overcome the problem could point me in the right direction.
Thanks very much.
Little Critter.
You need to detach your database from the server. Since you created the file there it is already running on the SQL Express server. Operating System Error 32 is a sharing violation and it means that the file is in use.
Try this:
Open Sql Express 2008 Managment Studio and find your database in the Object Explorer tree.
Right click on your database, choose tasks, and then select "Detach"
When the "Detach Database" dialog appears, select the checkbox that says "Drop Connections"
Click ok.
Your database should detach from the database server. Now the server will no longer bring that database up automatically and you should be able to get exclusive access to it.
Note that if you want to make more edits to the MDF you will have to reattach the database or you will need to use the tools built into VB 2008 Express. Because of this most people would choose to leave the database attached and not run it as a "User Instance". Check out this link for alternative ways to get to your data: How to: Access and Initialize Server Explorer/Database Explorer.
Anyway, you may have your reasons for setting it up this way. The steps outlined above should fix you up. Good luck with your project!

Why can't I open the same database files (.mdbs) in multiple environments at the same time?

This kind'a sucks. If I connect to a SQL Server DB (.mdb file) through VS.Net's server explorer, then I can't connect to the same file via SQL Server 2008 Management Studio at the same file. The file is locked.
For example, I get the following error from SQL Server Management Studio
CREATE FILE encountered operating
system error 32(The process cannot
access the file because it is being
used by another process.) while
attempting to open or create the
physical file 'C:\SQL Server 2000
Sample Databases\NORTHWND.MDF'.
(Microsoft SQL Server, Error: 5123)
I'm playing around with LINQ to SQL. So you would need to connect to VS.Net server explorer to drag in your table objects and create the .dbml files. However, if I want to query the database using old school SQL from management studio, I can't... I get the above error. Ditto if I try to connect using LINQPad (great tool...but useless thanks to this irritating file lock).
So does anyone out there know how I can connect to the same .mdb file from multiple programs like VS.Net's server explorer, SQL Server's management studio and LINQPad all at the same time?
Thanks!
By the way, this site is simply awesome and I love the fact that they made it in ASP.Net and used LINQ to SQL for data access... okay, off topic. Sorry.
The sql engine will lock the file once connected to it. nothing prevents you from attaching a file to an instance of SQL server and then connect to it from multiple applications.
The clue is in the name "SQL Server" - its seems that you can't attach the DB to two places which is not entirely unreasonable because you can't serve it twice (given that the server has responsibilities for things like transactions, logs, locking, etc).
So...
You want to "run" the database in an SQL Server instance and then connect from Visual Studio to that instance and then to the file rather than open the file directly (the option is there because it simplifies some deployment models) at which point you should get what you need.
As an aside, its perfectly possible to to "old school SQL" from within Visual Studio - although I'm not aware of an equivalent to LinqPad