Solved

How to open/connect to a ms access DB

Posted on 2006-11-29
6
1,099 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

710 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