473,403 Members | 2,183 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Full, simple, instructions for connecting my C# app to an Access database?

I'm new to this game. I can find my way around C# without any trouble,
and I've used Access, a little bit, in the past. Now a friend wants an
application of mine to read from his Access database. He's sent me the
..mdb file and a username and password, also an .mdw security file, and
I've tried to connect to it, using a couple of sample programs I found
on the web. Here's the critical code (<path>, <user>, and <password>
of course filling in for actual values):

static readonly string CONNECTION_STRING =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<path>.mdb;user
id=<user>;password=<password>";
....
connection_ = new OleDbConnection(Metadata.CONNECTION_STRING);
connection_.Open();

Which gives me this result:
Error :Cannot start your application. The workgroup information file is missing or opened exclusively by another user.


I have tried to establish the mdw file he sent me as my MS Access
Database, using the ODBC Data Source Administrator, but it made no
difference.

I do not have MS Access installed on my development machine.

I would appreciate a detailed but minimal set of instructions to get
this working. Thanks in advance.

Nov 13 '05 #1
7 3547
Try just storing the MDW in the same folder as the database of the same
name. I presume your colleague gave you a valid userid and password that are
defined in the MDW; if not, you need to get those if the database has been
secured. Alas, very few of us in this newsgroup do much with any of the
C-family of languages, and many of us don't do any ADO.NET, or don't do
much.

I trust you have installed and have references to the ADO.NET library for
C#, or perhaps the "classic" ADO library. At least the classic ADO library
is in the "MDAC" from Microsoft. If you don't have it already, download the
most current version and install it.

Not really pertinent to your particular issues, but just for the record,
Access is the user interface and development tool. The default database
engine used with Access is Jet. What you have is a Jet database -- those are
often called "Access databases". But Access can be used as a front-end to
any ODBC compliant database, and with ADO, to any database that has an ADODB
data provider.

You'll have a better chance of getting the answers you need if you will
visit a newsgroup that is devoted to ADO.NET or C# database access. I
suspect you'll be able to find one that is suitable at the free newsserver
news.microsoft.com.

Larry Linson
Microsoft Access MVP

<ca***********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I'm new to this game. I can find my way around C# without any trouble,
and I've used Access, a little bit, in the past. Now a friend wants an
application of mine to read from his Access database. He's sent me the
.mdb file and a username and password, also an .mdw security file, and
I've tried to connect to it, using a couple of sample programs I found
on the web. Here's the critical code (<path>, <user>, and <password>
of course filling in for actual values):

static readonly string CONNECTION_STRING =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<path>.mdb;user
id=<user>;password=<password>";
...
connection_ = new OleDbConnection(Metadata.CONNECTION_STRING);
connection_.Open();

Which gives me this result:
Error :Cannot start your application. The workgroup information file is
missing or opened exclusively by another user.
I have tried to establish the mdw file he sent me as my MS Access
Database, using the ODBC Data Source Administrator, but it made no
difference.

I do not have MS Access installed on my development machine.

I would appreciate a detailed but minimal set of instructions to get
this working. Thanks in advance.

Nov 13 '05 #2
Thanks, Larry.

I tried naming the .mdw file the same as the .mdb (it was already in
the same folder), to no avail. Thank you for the terminological
clarification, too. I'll go ask on another newsgroup.

--Carl

Nov 13 '05 #3
ca***********@gmail.com wrote in
news:11*********************@z14g2000cwz.googlegro ups.com:
I tried naming the .mdw file the same as the .mdb (it was already
in the same folder), to no avail. Thank you for the
terminological clarification, too. I'll go ask on another
newsgroup.


Um, you *never* want the MDW and the MDB file to have the same name
if they are stored in the same folder. The reason is that, given the
fact that an MDW is just a special kind of MDB, when it's in use,
there's a recordlocking file, *.LDB, with "*" being the name of the
MDB/MDW. If you've got the same file name for both, you end up with
a collision on the LDB file.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #4
<ca***********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
I'm new to this game. I can find my way around C# without any trouble,
and I've used Access, a little bit, in the past. Now a friend wants an
application of mine to read from his Access database. He's sent me the
.mdb file and a username and password, also an .mdw security file, and
I've tried to connect to it, using a couple of sample programs I found
on the web. Here's the critical code (<path>, <user>, and <password>
of course filling in for actual values):

static readonly string CONNECTION_STRING =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=<path>.mdb;user
id=<user>;password=<password>";
...
connection_ = new OleDbConnection(Metadata.CONNECTION_STRING);
connection_.Open();

Which gives me this result:
Error :Cannot start your application. The workgroup information file is
missing or opened exclusively by another user.


I have tried to establish the mdw file he sent me as my MS Access
Database, using the ODBC Data Source Administrator, but it made no
difference.

I do not have MS Access installed on my development machine.

I would appreciate a detailed but minimal set of instructions to get
this working. Thanks in advance.


You don't seem to have specified which mdw file to use. As part of the
connection string you could have:

"Jet OLEDB:System database=C:\MyFolder\MyWorkgroup.mdw"

Have a look at http://support.microsoft.com/kb/q191754/ for examples. Also
note that whether you are using ADO or ADO.NET one of the few things left
unchanged is the format of the connection string.

Nov 13 '05 #5
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.86...
ca***********@gmail.com wrote in
news:11*********************@z14g2000cwz.googlegro ups.com:
I tried naming the .mdw file the same as the .mdb (it was already
in the same folder), to no avail. Thank you for the
terminological clarification, too. I'll go ask on another
newsgroup.


Um, you *never* want the MDW and the MDB file to have the same name
if they are stored in the same folder. The reason is that, given the
fact that an MDW is just a special kind of MDB, when it's in use,
there's a recordlocking file, *.LDB, with "*" being the name of the
MDB/MDW. If you've got the same file name for both, you end up with
a collision on the LDB file.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc

A collision sounds dangerous, damaging, if not fatal. Have you tried this
yourself and found what damage is caused. Out of curiosity, I tried this
with AccXP and found that I could edit the database as normal. A single ldb
file is created with two entries per login.
Not that this is desirable, nor have I ever previously used the same
name/location for both files, but it does give more detail than the answer
"don't do this or there'll be a collision". Or perhaps you know further
details of the effects...


Nov 13 '05 #6
Thanks, Justin,

That worked beautifully. This is exactly the piece of information I
was missing. For the record, the mdw and mdb names were the same in
this case and it worked fine.

Peace,
--Carl

Nov 13 '05 #7
"Justin Hoffman" <j@b.com> wrote in
news:d9**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com:
"David W. Fenton" <dX********@bway.net.invalid> wrote in message
news:Xn**********************************@24.168.1 28.86...
ca***********@gmail.com wrote in
news:11*********************@z14g2000cwz.googlegro ups.com:
I tried naming the .mdw file the same as the .mdb (it was
already in the same folder), to no avail. Thank you for the
terminological clarification, too. I'll go ask on another
newsgroup.


Um, you *never* want the MDW and the MDB file to have the same
name if they are stored in the same folder. The reason is that,
given the fact that an MDW is just a special kind of MDB, when
it's in use, there's a recordlocking file, *.LDB, with "*" being
the name of the MDB/MDW. If you've got the same file name for
both, you end up with a collision on the LDB file.


A collision sounds dangerous, damaging, if not fatal. Have you
tried this yourself and found what damage is caused. Out of
curiosity, I tried this with AccXP and found that I could edit the
database as normal. A single ldb file is created with two entries
per login. Not that this is desirable, nor have I ever previously
used the same name/location for both files, but it does give more
detail than the answer "don't do this or there'll be a collision".
Or perhaps you know further details of the effects...


No, I've never done it. It makes no sense whatsoever to try it.

Either give the MDW a different name or put it in a different
folder.

I vote for changing the name, since users basically never know
anything about it. My policy on this is if the app is called
XYZ.mdb, then the MDW is XYZUsers.mdw.

--
David W. Fenton http://www.bway.net/~dfenton
dfenton at bway dot net http://www.bway.net/~dfassoc
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: John Morgan | last post by:
I have Enterprise Manager on my local machine. For the last twelve months it has been connecting without problem to my online SQL Server database provided by my ISP. Three weeks ago the ISP...
3
by: Simple Man | last post by:
We have a citrix server that users will be signing into from a remote location. One application is an Access database. Right now, lan users are using the Access 2003 runtime to run these...
12
by: Ann Marinas | last post by:
Hi all, I would like to ask for some help regarding separating the asp.net webserver and the sql server. I have created an asp.net application for a certain company. Initially, we installed...
2
by: SpoonfulofTactic | last post by:
I am building a Blog for my own person use, and I would like to be able to use unicode characters outside the range of the ascii set. However, when I use odbc to access table data, Access returns...
2
by: francois1 | last post by:
I am running a website with a SQL Server database attached. My transaction logs are full and my hosting co. won't allocate more disk space for me. I need to delete my database transaction logs...
5
by: yoyo | last post by:
Just to help somebody else if they are looking, we wasted 2 hours last night trying to figure out the problem. (With a manager over our shoulder) We upgraded our 8.1 FP11 instance to FP13....
2
by: Andy.I | last post by:
Hi I'm working on a little database application, and mst be cosnidered a newbie. What are the recomended way of making the database? Is it by adding a database file directy in my vb solution, or...
3
by: Blarneystone | last post by:
Ok, I've got a simple access 97 db. named S_tracking.mdb It has two tables 1- Jobs 2- Employees I've set up the references: Imports System.Data.OleDb Imports System.IO Imports System.data
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.