Simple clear advice in plain English

Hands on: From Access to SQL Server

How upsizing can affect VB code in forms, and using Access to manipulate SQL Server

Access project files
This month we’ll take a look at using Access to manipulate both the data and structure in SQL Server (the third and final option) and use an Access project file to do so. As a general rule you will need a version of Access that is more recent than the version of SQL Server; here I’ll use Access 2007 and SQL Server 2005.

Older Access versions will happily connect to younger SQL Server versions to manipulate the data but the combination of Access 2003 and SQL Server 2005 that I used in the Christmas issue won’t work now we want to create a new data structure.

Fire up Access and select New Blank Database. In the right-hand pane a default filename is shown with the .accdb extension for a normal database file. We want a project file so, with sublime disregard for intuitive use, you click on the tiny folder icon to the right (‘Browse for a location to put your database’).

In the File New Database window you can change the filename if you wish (I’m using AccessTest) and choose a project file by popping down the list of file types, selecting Microsoft Office Access Projects (*.adp) and clicking OK. Back on the Getting Started screen, click Create. When you’re asked whether you want to connect to an existing SQL Server database, answer No.

A dialogue opens asking ‘What SQL Server would you like to use for this database?’. It wants the name of the server to which you want to connect. You can use the server name or type:

(local)

if the server is on the same machine at which you are typing (but see below for more on this).
The letters SQL have been added to the filename you specified. Click Next and then Finish in the final dialogue. A progress bar is displayed while the project is created.

You’re now in Access with everything looking normal, except for the word ‘Project’ in the header at the top of the ribbon. But differences will start to appear as you work, so create a new Customer table. Enter a column name ­ CustomerID ­ and move on to setting its data type. The list of available types is much longer than the usual Access one, with many unfamiliar entries. It’s the first real indication we are using Access as a window into SQL Server.

Differences continue to appear: the CustomerID column is to be the primary key column in this table, but if you click the Primary Key button an error message appears, saying ‘Primary key cannot be created on column ‘CustomerID’ because it allows null values’. Sure enough, the Allow Nulls column in the table design view has been checked automatically. Why? Because that’s the default in SQL Server. You have to deselect the Allow Nulls setting before you can make the column a primary key column.

Article tags

Reader Comments

   

Add your comment

All fields must be completed. Your email address will not be displayed or used to send marketing messages.

All messages will be checked by moderators before appearing on the site.

See our Privacy Policy for more information.

Related articles

Manage files and folders with FarManager illustration

Bypass Windows and speed up the management of files and folders

Handle files and folders faster than ever by reverting to the time before Windows. For the confident, Far Manager works like the file-management tools of yesteryear

USB connection to a laptop

Set up an external hard disk and free up space on your computer

If you're short of space on your hard disk, there's a quick and easy solution

Word's undo feature

How to fix common PC errors

It’s easy to hit the wrong key when using a PC and throw yourself into a panic. There's no need to worry - we have easy fixes for 30 common everyday errors

Question & Answer

Q.Why are some of the keys on my keyboard doing strange...

> Read the answer

Q.Is my phone’s Bluetooth any use?

> Read the answer

Q.Can I switch boot drives so that I can work on older...

> Read the answer

Best deals on the web

img

Samsung RV520-A07

£359.98- Buy it now

img

Acer Aspire 5750G (LX.RXP02.019)

£399.99- Buy it now

img

Apple MacBook Pro (MD313B/A)

£904.37- Buy it now

Latest issue & subscription deals

Poll

Are you concerned about viruses that target mobile phones?

Jargon Buster

Computing terms explained in plain English

Virtual drive

A set of files seen by Windows as a separate hard disk.

Great shopping deals from Computeractive