Using a password protected Access database in VB.NET

Get help on programming - C++, Java, Delphi, etc.
Post Reply
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Using a password protected Access database in VB.NET

Post by ArmatageShanks »

Hello. I am a n00b. Yes, I am an IT student, but I'm a n00b one. Here is my current problem.

I'm trying to use an access database that's password protected in vb.net 2003, using the OleDbAdapter and the Microsoft Jet 4.0 OLE DB Provider, but it throws me this message when trying to test the connection:
VisualBasic.NET wrote:Test connection failed because of an error in initialzing provider. Cannot start your application. The workgroup information file is missing or opened exclusively by another user
Can anyone help?
xchuckx has been flushed and respawned neo-nymbo
Kronos
Moderator Emeritus
Posts: 4280
Joined: 28 May 2003, 02:00
Location: Azeroth
Contact:

Re: Using a password protected Access database in VB.NET

Post by Kronos »

ArmatageShanks wrote:Can anyone help?
The only honest help I can give you is to say:

NEVER, EVER!!! FOR EVER EVER!!!!!!!
Use either Access or VB.NET

Access is the worst excuse for a DB system.
Only capable of handling small amounts of data, and even then, something as stupid as flat files would be better.

And VB is, well. VB!

But I guess this is for a varsity project, so you don't really have a choice?
So I'll attempt to help, even though I don't approve of the choice of technology.

How do you set up the connection to the "DB"? Setting the properties of the controls, or in code?
Image
LordRage
Registered User
Posts: 2092
Joined: 08 May 2003, 02:00
Contact:

Post by LordRage »

I agree with the Access problem, however, the nice thing with Access, is it requires very little work to make the program run to a SQL DB later on in its life.

I do have to dissagree with the VB bashing, as VB is great for exactly that type of application, as long as you cos everything and dont just use the wizards, alot of industry uses that!!
Catch a man a fish, and you can sell it to him. Teach a man to fish, and you ruin a wonderful business opportunity. (Karl Marx)
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Post by ArmatageShanks »

@ Kronos. VB.NET is the language we 1st years are learning. Access is the only DB system I know how to use.
No, this is not for a project. I'm just experimenting.

To set up the DB connection, I use the OleDBDataAdapter control in the 'Data' tab in the toolbox. The wizard pops up and then I click 'New Connection', the 'Provider' tab, I choose the 'Microsoft Jet 4.0 OLE DB Provider'. I then browse for and select the DB file. On the 'Connection' tab, I uncheck the 'blank password' box, enter the password, click 'Test Connection' and then instead of the usual "Test Connection Succeeded", I get the above error message.
Last edited by ArmatageShanks on 23 Oct 2006, 13:19, edited 1 time in total.
xchuckx has been flushed and respawned neo-nymbo
Screeper
Registered User
Posts: 3692
Joined: 04 Apr 2003, 02:00
Contact:

Post by Screeper »

Do you have access to the DB? If you do, try disabling the password on the DB and then try creating the connection. Lets first make sure that it is the password bit that is causing the glitch.
That error doesn't look like a password error to me.

I did my final project with an Access DB and VB.NET - it was a bit of a pain to get Access to work smoothly with my application but it can be done, just takes some fiddling about.
There are 10 types of people in this world.
Those who understand binary and those who do not.
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Post by ArmatageShanks »

It works with the password disabled.

Otherwise, can anyone tell me how to make whatever source data a program is using (whether that may be a DB, text file, image) unreadable by a user?

e.g. This program I'm doing now is a simple Quiz one. The DB holds the questions and answers in a table. Now I don't want people to just be able to open the DB and see the answers. That's what the password is for.
xchuckx has been flushed and respawned neo-nymbo
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Post by Ron2K »

#ifndef VB_RANT
#define VB_RANT

VB... ugh.

VB is a poorly designed language that teaches one bad coding habits. No, don't ask me to explain - it's enough for you to know that I've been there and done that, so I'm speaking from experience here.

One of those bad habits is becoming dependent on a single vendor's (Microsoft) libraries, widgets and development tools. There is a prototype open-source implementation but it doesn't cover a lot of the language. This pretty much forces you to use Microsoft's implementation, which in turn locks you in to only those platforms that Microsoft chooses to support. As far as I'm concerned, any language that isn't fully supported by at least three operating systems from different vendors is a bad one to program in.

If you're forced to use VB, then I can sort of understand your situation, because that's where I came from. Just learn a better language as soon as you can. Once you've finished your course, you should be good enough to give C/C++ a go. If you absolutely insist of writing programs for the .NET framework, C# is far superior to VB, plus there's a decent open-source implementation (Mono).

As for Access - there's so many better database implementations out there.

#endif

To answer the question that you posed, I think I may have some code lying around at home - if so, I'll post back tomorrow.
Kia kaha, Kia māia, Kia manawanui.
ArmatageShanks
Registered User
Posts: 636
Joined: 01 Feb 2006, 02:00
Location: Cape Town

Post by ArmatageShanks »

C++ will come next year, then C# (at least that's what the Technical Programming lecturer told us this morning). All of them will be for the .NET framework.

I appreciate your help.
xchuckx has been flushed and respawned neo-nymbo
Kronos
Moderator Emeritus
Posts: 4280
Joined: 28 May 2003, 02:00
Location: Azeroth
Contact:

Re: Using a password protected Access database in VB.NET

Post by Kronos »

ArmatageShanks wrote:Hello. I am a n00b. Yes, I am an IT student, but I'm a n00b one. Here is my current problem.

I'm trying to use an access database that's password protected in vb.net 2003, using the OleDbAdapter and the Microsoft Jet 4.0 OLE DB Provider, but it throws me this message when trying to test the connection:
VisualBasic.NET wrote:Test connection failed because of an error in initialzing provider. Cannot start your application. The workgroup information file is missing or opened exclusively by another user
Can anyone help?
Find the workgroup information file.
Image
User avatar
Ron2K
Forum Technical Administrator
Posts: 9050
Joined: 04 Jul 2006, 16:45
Location: Upper Hutt, New Zealand
Contact:

Post by Ron2K »

OK, I couldn't find my VB .NET code anywhere (may have deleted it), so... this is how you would declare and initialize an OleDbConnection object with a password protected database in C#. It shouldn't be too difficult to convert this into VB .NET code.

Code: Select all

OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; User Id=whatever; Password=whatever; Data Source=Z:\wherever\yourdatabase.mdb");
Hope this helps...

(Someone please post if I've made any typing errors in all of that.)
Kia kaha, Kia māia, Kia manawanui.
DCStudios
Registered User
Posts: 14
Joined: 05 Oct 2006, 02:00
Location: Atlanta, GA, USA
Contact:

Post by DCStudios »

@ Kronos....

Visual Basic .NET [being a 3rd gen lang.] is one of the better up and coming languages. C sharp .net of course is ahead simply because of it's c-like syntax. VB can handle databases just as good as cpp; it just depends on how you code it. Code it right and it will do exactly what you need it to do. I still have yet to see somebody that wants to do something that cannot be done in Visual Basic .NET....


---------
http://www.vbdotnetforum.com
http://www.dc-studios.net
skunkymunky
Permanently Banned
Posts: 5906
Joined: 04 Mar 2003, 02:00
Location: The HoffPalace

Post by skunkymunky »

if u really wanna be fancy do this

in the Web.Config file under the configuration section

Code: Select all

<appSettings>
	<add key="strConn" value="Provider=Microsoft.JET.OLEDB.4.0;Data Source=" />
</appSettings>
in your webform.aspx

Code: Select all

Protected Connstr As String = _ ConfigurationSettings.AppSettings("strConn") & _ Server.MapPath("yourDatabase.mdb")

Dim conn As New OleDb.OleDbConnection(Connstr)
        strSQL = "SELECT * FROM sometable"
        Dim da As New OleDb.OleDbDataAdapter(strSQL, conn)
        dim ds as new DataSet

--do ur parameters and databindings here and walla
Fool people into thinking youve got a horse by taking off a unicorns horn
Post Reply