how to connect to MSAccess database??

how to connect to MSAccess database??

Post by narendar lokwan » Thu, 12 Oct 2000 04:00:00



i want SIMPLY to pick any data from a MS ACCESS database but i am  not
able to do it. some body please tell me the code with connection string
parameters.
 
 
 

how to connect to MSAccess database??

Post by Paul Browe » Thu, 12 Oct 2000 04:00:00


Here's how I do it.  You'll need the following declared in a regular module

'change the DB_NAME, DB_WRKGRP, LOGIN, PASSWORD to work with your
database/workgroup

Global Const DB_NAME                As String = "KOALADAT.MDB"     'data
Global Const DB_WRKGRP              As String = "KOALA.MDW"      'security
workgroup

Global PDBEng                       As DAO.PrivDBEngine
Global PWK                          As DAO.Workspace
Global PDB                          As DAO.Database

Private Const Foreign_DB_Login      As String = "developer"
Private Const Foreign_DB_Password   As String = "password"

'Create the Following function

Public Function SetDataEnv() As Boolean
On Error GoTo error:

    Set PDBEng = New DAO.PrivDBEngine
    PDBEng.SystemDB = GetWorkgroupPath()    'GetWorkgrouppath privides the
path to your access workgroup
    PDBEng.DefaultUser = Foreign_DB_Login
    PDBEng.DefaultPassword = Foreign_DB_Password
    Set PWK = PDBEng.Workspaces(0)
    Set PDB = PWK.OpenDatabase(GetDBPath())    'GetDbPath provides the path
to your access database
    SetDataEnv = True
    Exit Function
error:
    SetDataEnv = False
End Function

'Now, you can use the PDB object (Private Database Object) to open
recordsets, or whatever.  The syntax would be something like:

dim rs as dao.recordset
set rs = pdb.openrecordset("select * from tblPerson wher
LastName='Brower';")

I run the SetDataEnv when the project opens, and leave the PDB object set
until the program terminates.  Here's the function to close it down:

Public Function EndDataEnv() As Boolean
    If Not PDBEng Is Nothing Then
        Set PDBEng = Nothing
    End If
End Function

Good luck.
--
Paul Brower
http://www.browerconsulting.com
DO NOT EMAIL ME


Quote:> i want SIMPLY to pick any data from a MS ACCESS database but i am  not
> able to do it. some body please tell me the code with connection string
> parameters.


 
 
 

how to connect to MSAccess database??

Post by David » Thu, 12 Oct 2000 04:00:00


Is this in the Programmers' Guide?  That is the one manual I have yet to
purchase.


> Here's how I do it.  You'll need the following declared in a regular
module

> 'change the DB_NAME, DB_WRKGRP, LOGIN, PASSWORD to work with your
> database/workgroup

> Global Const DB_NAME                As String = "KOALADAT.MDB"     'data
> Global Const DB_WRKGRP              As String = "KOALA.MDW"      'security
> workgroup

> Global PDBEng                       As DAO.PrivDBEngine
> Global PWK                          As DAO.Workspace
> Global PDB                          As DAO.Database

> Private Const Foreign_DB_Login      As String = "developer"
> Private Const Foreign_DB_Password   As String = "password"

> 'Create the Following function

> Public Function SetDataEnv() As Boolean
> On Error GoTo error:

>     Set PDBEng = New DAO.PrivDBEngine
>     PDBEng.SystemDB = GetWorkgroupPath()    'GetWorkgrouppath privides the
> path to your access workgroup
>     PDBEng.DefaultUser = Foreign_DB_Login
>     PDBEng.DefaultPassword = Foreign_DB_Password
>     Set PWK = PDBEng.Workspaces(0)
>     Set PDB = PWK.OpenDatabase(GetDBPath())    'GetDbPath provides the
path
> to your access database
>     SetDataEnv = True
>     Exit Function
> error:
>     SetDataEnv = False
> End Function

> 'Now, you can use the PDB object (Private Database Object) to open
> recordsets, or whatever.  The syntax would be something like:

> dim rs as dao.recordset
> set rs = pdb.openrecordset("select * from tblPerson wher
> LastName='Brower';")

> I run the SetDataEnv when the project opens, and leave the PDB object set
> until the program terminates.  Here's the function to close it down:

> Public Function EndDataEnv() As Boolean
>     If Not PDBEng Is Nothing Then
>         Set PDBEng = Nothing
>     End If
> End Function

> Good luck.
> --
> Paul Brower
> http://www.browerconsulting.com
> DO NOT EMAIL ME




- Show quoted text -

Quote:> > i want SIMPLY to pick any data from a MS ACCESS database but i am  not
> > able to do it. some body please tell me the code with connection string
> > parameters.

 
 
 

how to connect to MSAccess database??

Post by Paul Browe » Thu, 12 Oct 2000 04:00:00


Is WHAT in the programmers guide?  I wrote this code myself.  If I had taken
it from somewhere, that source would be acknowledged.

FYI - the PrivDBEngine is not documented anywhere (except for maybe a blurb
on my website).

--
Paul Brower
http://www.browerconsulting.com
DO NOT EMAIL ME


> Is this in the Programmers' Guide?  That is the one manual I have yet to
> purchase.



> > Here's how I do it.  You'll need the following declared in a regular
> module

> > 'change the DB_NAME, DB_WRKGRP, LOGIN, PASSWORD to work with your
> > database/workgroup

> > Global Const DB_NAME                As String = "KOALADAT.MDB"     'data
> > Global Const DB_WRKGRP              As String = "KOALA.MDW"
'security
> > workgroup

> > Global PDBEng                       As DAO.PrivDBEngine
> > Global PWK                          As DAO.Workspace
> > Global PDB                          As DAO.Database

> > Private Const Foreign_DB_Login      As String = "developer"
> > Private Const Foreign_DB_Password   As String = "password"

> > 'Create the Following function

> > Public Function SetDataEnv() As Boolean
> > On Error GoTo error:

> >     Set PDBEng = New DAO.PrivDBEngine
> >     PDBEng.SystemDB = GetWorkgroupPath()    'GetWorkgrouppath privides
the
> > path to your access workgroup
> >     PDBEng.DefaultUser = Foreign_DB_Login
> >     PDBEng.DefaultPassword = Foreign_DB_Password
> >     Set PWK = PDBEng.Workspaces(0)
> >     Set PDB = PWK.OpenDatabase(GetDBPath())    'GetDbPath provides the
> path
> > to your access database
> >     SetDataEnv = True
> >     Exit Function
> > error:
> >     SetDataEnv = False
> > End Function

> > 'Now, you can use the PDB object (Private Database Object) to open
> > recordsets, or whatever.  The syntax would be something like:

> > dim rs as dao.recordset
> > set rs = pdb.openrecordset("select * from tblPerson wher
> > LastName='Brower';")

> > I run the SetDataEnv when the project opens, and leave the PDB object
set
> > until the program terminates.  Here's the function to close it down:

> > Public Function EndDataEnv() As Boolean
> >     If Not PDBEng Is Nothing Then
> >         Set PDBEng = Nothing
> >     End If
> > End Function

> > Good luck.
> > --
> > Paul Brower
> > http://www.browerconsulting.com
> > DO NOT EMAIL ME




- Show quoted text -

Quote:> > > i want SIMPLY to pick any data from a MS ACCESS database but i am  not
> > > able to do it. some body please tell me the code with connection
string
> > > parameters.

 
 
 

1. Problem with connecting to MSAccess database

Hi,

I am using JBuilder to write an applet to display/update data from/to a
MSAccess database.  The applet works perfectly on the NT 4.0 machine
using Netscape 4.04 and Java 1.1.4.  But when I load the applet from a
Win95 machine using the same Netscape 4.04 and Java 1.1.4, I get the
following error:
#Security Exception: checkpropsaccess.key
#Verifier error
borland/jbcl/control/UserNamePassordDialog.<init>(Ljava/lang/String;Lborland/jbcl/dataset/Database;)V:Expectin
to find object/array on stack
#Security Exception: cannot define package:java.text.resources

Any help will be greatly appreciated. Thanks for your time and response.

Tan

2. JDBC-ODBC Error on NT

3. Can't connect to MSAccess database on different server which the Web ASP app is running

4. SDK problem

5. connecting a password secured MSAccess Database

6. SQL Server 6.5 Scheduler

7. Java Applet or Application to Connect to Informix / MsAccess Database

8. Recordsets Using ADO and Oracle Stored Procedures

9. ADO DataEnvironment, Connect MSAccess database that has password

10. Connecting to an unknown MSAccess Database for information

11. connecting to msaccess using sql/odbc from ansi c

12. BDE trying to connect to MSACCESS

13. BDE Connect MSACCESS Problem?