Visual Studio 2005 and Access database mystery

S

surfrat_

Hi,

I am having the following problems in getting Microsoft Visual Studio
2005 Professional to link to an Access .mdb

database. Please help me to sort this out.

Problem 1:

The Microsoft page "How to: Connect to Data in an Access Database"

http://msdn2.microsoft.com/en-us/library/cf131f6b.aspx states the
following on how to connect to a Access database:

1. On the Data menu, click Add New Data Source.

2. Select Database on the Choose a Data Source Type page.

3. Select New Connection to create a new data connection.

Note
If the Data source is not Microsoft Access Database File, then select
Change to open the Choose/Change Data Source

dialog box, select Microsoft Access Database File, and then click
Continue.


4. The default provider is .NET Framework Provider for OLE DB. For more
information, see Choose/Change Data Source

Dialog Box.

5. In the Database file name box, enter the path to the .mdb file, or
click the Browse button to locate the database

file.

6. Enter login information if required by your database. For more
information, see Add/Modify Connection (Microsoft

Access).

7. Click OK, and then click Next.

In step 5 above it talks of a browse button. I dont't get that but
rather am given a dialog box titled Add Connection

and the only option is ConnectionString. I have tried all sorts of
options for a connect string but allways get the

error message "Format of the initialization string does not conform to
specification starting at index 0"


Problem 2:
From the same page it states: "Drag an .mdf or .mdb file from Windows
Explorer into Solution Explorer to

automatically configure your connection and start the Data Source
Configuration Wizard ready for you to select the

objects to use in your application."

When I drag and drop drop an Access database eg. Northwind.mdb into the
Solution Explorer window I get the following

error: "An eror occurred while processing the local data file: Object
reference not set to an instance of an object"

Questions:

1. In problem 1 why don't I get the correct dialog with browse
functionality? I have Microsoft Visual Studio 2005

Professional installed on my Laptop and my main PC and they both do the
same thing. I have all patches and updates

installed.

2. How do I resolve problem 2? I have searched for a solution and and
have found none. I have uninstalled .Net

Framework 2 and reinstalled it with no difference. I think the two
problems are related.

Thanks very much for your help.

Surfrat.
 
C

ChrisM

Hi,

Do you actually have Access installed on the computers?
Is it possible that you don't have the necessary ODBC drivers (or whatever)
to connect to an Access database?

Cheers,

Chris.
 
S

surfrat_

Hi chris,

Yes I have Access 2003 on both machines...

I can access the databases fine from Access.

Thanks

SurfRat
 
C

ChrisM

Hmmm, you are selecting the 'Microsoft Jet...' provider aren't you?

Sorry to ask these dumb questions, it just strange the the provider doens't
seem to know that you want to open an Access database, and giving you the
correct dialog to select it...

Cheers,

Chris.
 
S

surfrat_

Hi Chris,

Thanks for your help. I click on new connection and select "Microsoft
Access database file" at the top under Data Source which in turn
selects ".Net Framework Data Provider for OLE DB" under Data Provider.
When I then click OK I get the "Add Connection" dialog with only
ConnectionString and no browse button. I will see what help I get from
the news groups over the weekend and then uninstall Visual Studio and
..Net Framework 2.0 and try again.

Does your VS2005 work correctly? I have Visual Studio 2005 Pro
installed v8.0.50727.42
(RTM.050727-4200) and .Net Framework v2.0.50727. How do these compare
to you versions?

Cheers

SurfRat.
 
C

ChrisM

Hi,

Have to admint that I'm still using VS2003, and how now experience of 2005.
I was hoping that it would be similar enough for my suggestions to be able
to help, but maybe they are too different in this area...

Last thing I can think of:
Can you change the DataProvider that it suggests? Is there any others
available that mention Access or Jet?

Cheers,

Chris.
 
S

surfrat_

Yes there are other data providers...

Dataprovider for ODBC
Dataprovider for SQL server
Dataprovider for SQL server mobile edition
Dataprovider for Oracle

Thanks...
 
S

surfrat_

Hi,

I installed VS2005 on another PC with a vanilla copy of XP Pro. The
problem is not present and the browse button is available.

I then uninstalled VS2005, SQL and .Net framework 2.0 and reinstalled
everything and the problem is still there. I am now thinking that the
problem is caused by something else. Ideas would be welcome...

Thanks

SurfRat.
 
C

ChrisM

What else is installed on the problem PC that isn't present on the vanilla
one?

When you get the browse button on the vanilla PC, is it using EXACTLY the
same provider as when it doesn't work on the other one?

Chris.
 
S

surfrat_

Hi,

The vanilla PC has only WinXP and VS2005 with no updates or patches. My
main PC has all the updates and patches for everything and loads of
apps eg. Office 2003, anti virus. My laptop and main PC are both fully
updated and have similar apps. Yes, exactly the same provider is used
in both cases. I also tested the scenario where you can drag a .mdb
file into your project. On the vanilla PC it worked fine but on my main
PC and my laptop I get the error message.

Something is interfearing with the ADO porion of the .Net framework.

Thanks

SurfRat.
 
C

ChrisM

Yuck!

Well, the only thing I can think of is to slowly install all the patches and
apps onto the vanilla PC until it starts to show the same problem. Once
you've identified the patch/application that causes the problem, then you
can start trying to work out how you're going to fix it...

I guess installing Office2003 on the vanilla PC would be a good candidate to
try first, along with any other databasey type applications...

Good luck...!

Chris.
 
S

surfrat_

Hi,

My only way around this was a complete fresh install of Windows and
Visual Studio. Now VS2005 works correctly.

SurfRat.
 
C

ChrisM

Oh well, at least you're working again now.
You'll have to try and remember to check it still works everytime you
install/upgrade anything and see ifyou can ever work out what messed it up
in the first place...
 
V

vemund

I have the same problem. Haven't found any way around this problem yet,
because there isn't an option for me to completely reinstall my
laptop since I am in the middle of a project.
But I think it happens because I have different version of Visual
studio installed. I am using Visual Studio 6.0, Visual studio 2003 and
Visual studio 2005 on my laptop. Some kind of dll hell...
The problem is really frustrating since I have a deadline coming up.
Any help would be appreciated.


ChrisM skrev:
 
L

Liddle Feesh

ChrisM said:
Oh well, at least you're working again now.
You'll have to try and remember to check it still works everytime you
install/upgrade anything and see ifyou can ever work out what messed it up
in the first place...

I've got exactly the same problem, not sure what's causing it yet either...
 
C

Curt

I Highly recomend that you download the FREE Virtual PC from Microsoft.
It lets you create a Virgin environment, then copy the .vhd file and
maintain a virgin install for any purpose you choose, like testing etc.
You can then delete the original and copy is back in a few seconds and
have a brand new install to test with again. Its a GREAT Free Tool
 
C

ChrisM

I'd second that.
Totally fantastic tool. When I was doing one project, I had 3 virtual PCs
running on my desktop. One running XP, one 2000 and one Win95. Could copy
environments, return a PC to 'virgin' status etc etc all in a few moments.

As Curt says, really really good tool.

Chris.
 
V

vemund

I know and I am using it especially for testing clients in a clean
environment. But I think there is a little performance issue when you
are developing through Virtual PC.
Anyway it does not help me to get my laptop and environment good again
without reinstalling windows:-|

-Vemund

ChrisM skrev:
 
C

ChrisM

Yea, Ok. Apologies for my somewhat off topic post.

You are right. I don't think that DEVELOPING on a Virtual PC would be, in
any way, a good idea!

Do you actually need all 3 versions of VS on you laptop for this current
project you're working on?
If you suspect this to be the problem, can't you uninstall anything you
don't need for this project and maybe (just maybe) it could help... :-/

As a last resort, and if it is causing you severe problems, I can't see why
you can't back up all your project files and test data and whatever else.
ReInstall your laptop, then restore all the project stuff. Might be a pain
in the a** and take some effort, but might be worth it in the long run... ?

Chris.

vemund said:
I know and I am using it especially for testing clients in a clean
environment. But I think there is a little performance issue when you
are developing through Virtual PC.
Anyway it does not help me to get my laptop and environment good again
without reinstalling windows:-|

-Vemund

ChrisM skrev:
I'd second that.
Totally fantastic tool. When I was doing one project, I had 3 virtual PCs
running on my desktop. One running XP, one 2000 and one Win95. Could copy
environments, return a PC to 'virgin' status etc etc all in a few
moments.

As Curt says, really really good tool.

Chris.

Curt said:
I Highly recomend that you download the FREE Virtual PC from Microsoft.
It lets you create a Virgin environment, then copy the .vhd file and
maintain a virgin install for any purpose you choose, like testing etc.
You can then delete the original and copy is back in a few seconds and
have a brand new install to test with again. Its a GREAT Free Tool





"Liddle
Feesh" <liddlefeesh]at[gmail.com> says...
Oh well, at least you're working again now.
You'll have to try and remember to check it still works everytime
you
install/upgrade anything and see ifyou can ever work out what messed
it
up
in the first place...

I've got exactly the same problem, not sure what's causing it yet
either...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top