Access databases can not be used in VS 2005

G

Guest

Hi all,

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.

Note: I have also had VS.NET 2002 in parallel on the same box, which had
been uninstalled in the meantime. So I reinstalled VS 2005 too, but the
problem remains. However ODBC for Access databases works, but this is not
wanted.

Thanks in advance, Fritz
 
P

Paul Clement

¤ 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"

In step three when you click on New Connection, change the Data Source to Microsoft Access Database
File and then click on the Browse command button to select the file name. That should take you to
step seven.

¤ 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"

I can't reproduce this issue.

Sounds like you might have a bad install.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
G

Guest

Thanks so far.

See inline, commented with Fritz.

--
Fritz Theiss


Paul Clement said:
¤ 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"

In step three when you click on New Connection, change the Data Source to Microsoft Access Database
File and then click on the Browse command button to select the file name. That should take you to
step seven.

Fritz: No, it does not. There is no browse button available.
¤ 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"

I can't reproduce this issue.

Fritz: I believe so as I can´t reproduce either on a different machine,
having VS.NET 2002 not installed previously.
Sounds like you might have a bad install.

Fritz: I know. The question is: How to get rid of this? As written:
Reinstallation of VS 2005 did not help. From a different thread I saw that
this guy completely(!) reinstalled his machine in order to have this problem
fixed. This option is not available to me.
 
P

Paul Clement

¤ Any (further) ideas are appreciated.

I would uninstall any versions of Visual Studio.NET you have installed. Also, uninstall all versions
of the .NET Framework and make sure to delete any files or folders that are left over before
reinstalling.


Paul
~~~~
Microsoft MVP (Visual Basic)
 
G

Guest

As written previously - I have uninstalled both versions of VS and only
re-installed VS 2005. Ok, I did not uninstall .NET Framework. But this I
declined on purpose.

Due to another issue in the past, I have contacted MS Support: Their
recommendation in case of un-installing .NET Framework is: Re-install the
complete box due to appearing inconsistencies. And this is - as said - not on
my radar...
 
D

Drew

I've also just recenlty run into this problem and would like to know how
to fix it.

I've installed it on a laptop & workstation with the only signinficant
difference between the two being that the laptop has Office 2007 on it
(and this is the machine it does NOT work on) and the workstation has
Office XP (and this is the machine it DOES work on).

This problem has signinficant decreased my productivity since I now have
to manually create all the connection objects, data adpater objects, and
(worst of all) configuring the Grid View control controls for the
resulting dataset.

I am also in a position where a complete uninstall of Windows XP is not
an option.

Thank you,

Drew
 
D

Drew

I've also just recenlty run into this problem and would like to know how
to fix it.

I've installed it on a laptop & workstation with the only signinficant
difference between the two being that the laptop has Office 2007 on it
(and this is the machine it does NOT work on) and the workstation has
Office XP (and this is the machine it DOES work on).

This problem has signinficant decreased my productivity since I now have
to manually create all the connection objects, data adpater objects, and
(worst of all) configuring the Grid View control controls for the
resulting dataset.

I am also in a position where a complete uninstall of Windows XP is not
an option.

Thank you,

Drew

I think I might have a solution.
I noticed my Server Explorer had a Data Connection to a local instance
of
a SQL server that I no longer have on my laptop, so I removed it.

On a lark, the next time I opened VS 2005 I thought I'd give the Access
Data Connection another try and this time it worked!

I'm guessing if you still have a problem, check your other Data
Connections listed in the Server Explorer and remove any that you aren't
using. Worth a shot!
 
G

Guest

Ok, I am having the same problem. I have deleted all my connections and
tried it again, and it did not fix it. I have VS2003 and VS2005 on my
machine and have uninstalled and reinstalled VS2005 to no avail.
In my case, this was working at one time and has stopped! The only
significant change I have made to this machine was to upgrade IE from version
6 to 7.

Anyone have anymore ideas?
 
G

Guest

I am also meeting the same problem: an error when I try to mak e connection
using the wizard. Hope anyone can give a working syntax solution for the
connectionstring.

Had no problems connecting a mdb in VB6, but it seems not to work in VS
express 2005
 
G

Guest

Hi Jan,
I don't think anyone has figured out what is going on here. My problem
just disapeared one day. In the meantime, you might want to setup an ODBC
connection to your access database and use it instead of the OLE DB provider.
 
G

Guest

Try this
assume xxx.mdb contains a table called 'table name' which contains ID,
lname, fname.
string constring= "provider= Microsoft.Jet.OLEDB; Data source= c:\xxx.mdb";
OlebConnection connection= new Oledbconnection(constring);
connection.Open();
OleDataadapter da= new Oledataadapter ("Select * from table name",connection);
Dataset ds= new Dataset();
da.fill(ds,"table name");
connection.Close();
foreach(DataRow d in ds.Tables[table name].Rows)
{
MessageBox.Show("Ifound "+ d["lname"].ToString()+" "+d["fname"].ToString());
}


You may also use a dataview to find data

Dataview DV= new DataView(ds.Tables[table name"],"","fname",Dataviewoptions.
none);

int f= DV.Find("frank");

if (f > -1)
{
MessageBox. Show( "I found Frank at row"+ f);
or MessageBox.Show (DV[f]["fname"].ToString() +" "+
DV[f]["Lname"].ToString()+ " was found at row "+f );

}
 

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