Solved

How to open/connect to a ms access DB

Posted on 2006-11-29
6
1,101 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

622 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