Solved

How to open/connect to a ms access DB

Posted on 2006-11-29
6
1,097 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
ID: 18042506
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
ID: 18042656
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
ID: 18054702
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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

Author Comment

by:Steve7423
ID: 18055258
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
ID: 18055829
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
ID: 18056188
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

820 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