简体   繁体   中英

Can't connect MS Access front end to SQL Server back end

I have imported data to SQL Server Express from MS Access and have tried to link to the data from an Access front end file.

I have tried several different login types, but each gives me the same error:

Error Locating Server/Instance Specified

Please help.

Assuming a local instance of SQL server?

The default is usually YOURCOMPUTERNAME\SQLEXPRESS.

But, you can use a "." (dot) in place of your computer name. So, the server name should be.\SQLEXPRESS

A few things: When you setup and attempt to connect? Always create a FILE dsn. The reasons for this are many, but one really nice reason is that then Access will by default create a DSN-LESS connection. This approach is preferred since then Access remembers the settings, and no external settings (such as registry or even a file (dsn) is used or required. And if you connect to a SQL server on your network? Well then you can distribute the access application to each workstation, and it will "just work" - all without you having to setup a DSN or do anything with the ODBC manager on each station. So, a great tip and habit. So, use a FILE dsn (and if you follow the default prompts when linking tables, a FILE dsn is the default anyway).

Next up: Make sure the sql server browser service is running. In the past this was often not required, but now it is recommended. That service is this:

在此处输入图像描述

Once you sure that service is running?

Make sure that you enabled named Pipes - in fact I would also enable TCP/IP. That is found here:

在此处输入图像描述

Ok, now the next question: Are you using SQL server logons, or Windows authentication?

For now since this is your local stand alone machine? lets go with windows.

As noted, if you have SSMS installed, then see if it can connect. This not only is a quick + easy fast test but it will also tend to give you the hints as to what the server name connect is. (this helps you when you attempt to connect with Access - you can see what worked with SSMS - and better is SSMS does usually figure out the correct computer name for you.

So, from Access, you now choose from ribbon "External" data, and then import and link group - choose ODBC.

the wizard to connect will start. choose "link to the data source".

At this point, the panels that start to launch are the same one you see if you try to use the ODBC manager from the control panel - but in most cases this road is better, since Access will correctly launch the x32 or x64 bit ODBC manager (it makes this correct decision for you).

So you be at a DSN name, but just hit new. Now you have to choose a ODBC (for sql server) driver.

在此处输入图像描述

For now, I would try "SQL server". You can choose SQL Server Native Client 11 (or later if you see). Either one is fine. Just keep in future mind that SQL Server driver choice exists on all computers - so for future distribution to other workstations, this is a good choice. The native 11 (or later) driver is NOT installed by default, and you have to install this on other workstations if you want to use that driver if you move or distribute your application to other workstations.

Next, and now you can enter a name for this connection (myTestcon or whatever). Hit finish.

You should now see/be at this screen:

在此处输入图像描述

The dropdown for the server name SHOULD appear and work (it make take 30 seconds). So, it should show you a server name, and a sql instance.

Next, and now you have to choose the type of logon

Because this is a local stand alone computer? Well, you can choose windows logons, or sql logons. Being a local computer - choose the default - windows auth.

在此处输入图像描述

Next.

NOW VERY VERY important - make sure you change/select the correct database here - SO MANY skip or miss this - and that's painful!!

This one:

在此处输入图像描述

So make sure you select/change the default from "master" to your database you created when you sent the data to sql server.

Next - (you can try the test data source). "ok".

Now you are back to the VERY same starting panel. Your "name" should be defaulted for the file connection. This:

在此处输入图像描述

So, now just click ok.

You can then select the tables you want to link to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM