473,405 Members | 2,160 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,405 software developers and data experts.

jet code fails with password, why ?

The following function fails if the Jet database has a password. This is the
error:
{"Cannot start your application. The workgroup information file is missing
or opened exclusively by another user." }

However the same Jet database opens easily with VB 6. Thereis no MDW (
workgroup file - never has been. ). So what is happening: ??

public bool testOpenJet( string strDbPath, string pwd)
{
try
{
string sCnnString= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
System.Data.OleDb.OleDbConnection jetConn = new OleDbConnection();
sCnnString+= sCnnString + strDbPath;
if (pwd.Length>0)
{
sCnnString+= ";Password="+ pwd;
}
jetConn.ConnectionString=sCnnString;
jetConn.Open();
jetConn.Close();
return true;
}
catch ( Exception e)
{
Console.WriteLine(e.Message);
}
return false;
}

VB 6 CODE:
Private Sub Form_Load()
Dim db As DAO.Database
Dim AccessPath As String
Dim dbPassword As String
dbPassword = "test"
AccessPath = "c:\password.mdb"
Set db = OpenDatabase(AccessPath, False, False, ";pwd=" & dbPassword)
End Sub

--
Andrew
Nov 16 '05 #1
3 2257
andrewcw <an******@acw.com> wrote:
The following function fails if the Jet database has a password. This is the
error:
{"Cannot start your application. The workgroup information file is missing
or opened exclusively by another user." }

However the same Jet database opens easily with VB 6. Thereis no MDW (
workgroup file - never has been. ). So what is happening: ??

public bool testOpenJet( string strDbPath, string pwd)
{
try
{
string sCnnString= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
System.Data.OleDb.OleDbConnection jetConn = new OleDbConnection();
sCnnString+= sCnnString + strDbPath;


There's a bug to start with - your connection string after this
statement will have the "Provider=" bit twice. You either mean

sCnnString = sCnnString + strDbPath;
or
sCnnString += strDbPath;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
Thanks for the first bug
but when the connection string is coorected and looks like this:
"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\password.MDB;Password=test"

I still get "Cannot start your application. The workgroup information file
is missing or opened exclusively by another user"

Why ? What else could be wrong ? I dont need a workgroup file for DAO.

"Jon Skeet [C# MVP]" wrote:
andrewcw <an******@acw.com> wrote:
The following function fails if the Jet database has a password. This is the
error:
{"Cannot start your application. The workgroup information file is missing
or opened exclusively by another user." }

However the same Jet database opens easily with VB 6. Thereis no MDW (
workgroup file - never has been. ). So what is happening: ??

public bool testOpenJet( string strDbPath, string pwd)
{
try
{
string sCnnString= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
System.Data.OleDb.OleDbConnection jetConn = new OleDbConnection();
sCnnString+= sCnnString + strDbPath;


There's a bug to start with - your connection string after this
statement will have the "Provider=" bit twice. You either mean

sCnnString = sCnnString + strDbPath;
or
sCnnString += strDbPath;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
Precisely there are a lot of sights with incorrect and misleading ideas on
passwords. With JET & oledb you must format the connection string as follows:
http://www.connectionstrings.com/

;Jet OLEDB:Database Password="+ pwd;

SIMPLY Password or pwd simply does not work and brings up misleading errors
"Jon Skeet [C# MVP]" wrote:
andrewcw <an******@acw.com> wrote:
The following function fails if the Jet database has a password. This is the
error:
{"Cannot start your application. The workgroup information file is missing
or opened exclusively by another user." }

However the same Jet database opens easily with VB 6. Thereis no MDW (
workgroup file - never has been. ). So what is happening: ??

public bool testOpenJet( string strDbPath, string pwd)
{
try
{
string sCnnString= "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=";
System.Data.OleDb.OleDbConnection jetConn = new OleDbConnection();
sCnnString+= sCnnString + strDbPath;


There's a bug to start with - your connection string after this
statement will have the "Provider=" bit twice. You either mean

sCnnString = sCnnString + strDbPath;
or
sCnnString += strDbPath;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4

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

Similar topics

1
by: Phil Powell | last post by:
/*-------------------------------------------------------------------------------------------- This function will utilize the ability to use HTTP-based WWW Authentication, checking for the global...
8
by: alanstew | last post by:
With the body tag calling out 'window onload', a function with a 'window.open' fails at the 'window.open' line. If I cut out the body tag, the function executes as normal. At first I thought it...
2
by: MLH | last post by:
I have not yet tried running this code in Access 97. It was ported from Access 2.0. It fails to compile, failing on the line xxxxxxxxxxxxxxxxxxx Function MakeUsersFromTable(TableName As String,...
4
by: marco.nl | last post by:
it fails to retrieve newly intruduced data by the user. i tried this ... AfxGetApp()->WriteProfileString("Settings", "email", EDIT1); UpdateData(FALSE); and this.....
2
by: Naeem Sarfraz | last post by:
Any advice for the following situation? I've deployed my webservice on a remote server, e.g. http://mywebservice.co.uk/summary.asmx. The windows clients attempts to access this webservice and...
8
by: VB Programmer | last post by:
I would appreciate your assistance on this ASP.NET 2.0 site.... This is the wierd problem: While accessing the built in .NET functions for 'profiling' or 'membership' an error is generated (see...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
8
by: Radu | last post by:
Hi. This code worked fine with SQL2005, but has a problem with SQL2000.... Which one ???? cnSQL = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))...
8
by: Brett | last post by:
I wrote an ASP.NET application that queries a SQL Server database (on a different box from the web server) and displays the result in a GridView. The datasource for the GridView is a SQLDataSource....
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.