Solved

How to open/connect to a ms access DB

Posted on 2006-11-29
6
1,091 Views
Last Modified: 2008-02-01
I'm looking for the script to open a Access DB from a proceedure in sql.  Then I need to create a recordset object and be able to refer records in that object.  here's the suedo code

open ACCDB
create recordset based on a customer name
      If the name doesn't exist in AccDB then create new record

I'm new to SQL scripting coming from a VB and C# background so my methods differ from sql scripting.

any code examples??
 

0
Comment
Question by:Steve7423
  • 3
  • 2
6 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 200 total points
Comment Utility
Hi Steve7423,


This example accesses the orders table in the Microsoft Access Northwind database through the Microsoft OLE DB Provider for Jet.



Note  This example assumes that Access is installed.


USE pubs
GO
SELECT a.*
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
   'c:\MSOffice\Access\Samples\northwind.mdb';'admin';'mypwd', Orders)
   AS a
GO



Cheers!
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
For a pure MS Access solution you should post in a more appropriate Topic Area such as:
http://www.experts-exchange.com/Databases/MS_Access/
0
 

Author Comment

by:Steve7423
Comment Utility
aneeshattingal

Your assumption of Access installed is a good one.  it's very likely that in this case, Access will not be installed.  how will this change the script?

0
Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

 

Author Comment

by:Steve7423
Comment Utility
Ok, I've researched Openrowset, the overall method is intreguing though it requires the provider and it's very likely there won't be one.

I'm trying to emulate VB code.

Example:

create a connection object to a database with user and PW
use the object to open tables in a Access DB and add records.

I'm trying to learn the proper script for this in SQL.  the syntax to do so differs between VB, .net, and SQL.

are there any other SQL methods to open databases?

0
 

Author Comment

by:Steve7423
Comment Utility
I've played with this a bit and it meets my needs except the provider concerns me.

Question, If I'm accessing the mdb on a network computer that does not have Access installed, which coomputer does the provider need to be on.


Note: users have the option of copying the mdb file to any location on the network, regardless of jet installation.
 
0
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 50 total points
Comment Utility
It is quite simple:  If you are using the JET provider the computer that is running the application must have the JET drivers installed (they do not need MS Access installed)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now