473,395 Members | 1,791 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,395 software developers and data experts.

access MS-Access database in C# Windows Application

Hi, I am trying to access the MS Access database on my local machine
in C# Windows Application in Visual Studio.NET.

But it seems that it does not work. I use the Microsoft Application
Blocks to access the database.

I have tried 2 possible connection strings.

-----------------------------------------

str_1 = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" + DBFilePath;

str_2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBFilePath;

//SqlHelper is the class in the Microsoft Application Blocks
SqlHelper.ExecuteNonQuery( str_1, CommandType.Text, SQL_str);
-----------------------------------

The error message I got is:

"Unknown connection option in connection string: driver." for str_1

and
" Unknown connection option in connection string: provider." for str_2

So I am wondering, where is the problem?
Is it because my connection string for MS Access is specified wrongly?
Or is it because I cannot use SqlHelper to access the MS Access
database? ( I have used SqlHelper class to access the MS SQL server,
and it works)

Your help will be greatly appreciated.
James
Nov 12 '05 #1
1 5326
James wrote:
Hi, I am trying to access the MS Access database on my local machine
in C# Windows Application in Visual Studio.NET.

But it seems that it does not work. I use the Microsoft Application
Blocks to access the database.

I have tried 2 possible connection strings.

-----------------------------------------

str_1 = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" + DBFilePath;

str_2 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + DBFilePath;

//SqlHelper is the class in the Microsoft Application Blocks
SqlHelper.ExecuteNonQuery( str_1, CommandType.Text, SQL_str);
-----------------------------------

The error message I got is:

"Unknown connection option in connection string: driver." for str_1

and
" Unknown connection option in connection string: provider." for str_2

So I am wondering, where is the problem?
Is it because my connection string for MS Access is specified wrongly?
Or is it because I cannot use SqlHelper to access the MS Access
database? ( I have used SqlHelper class to access the MS SQL server,
and it works)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm still learning about C# and ADO.NET, so ...

Usually, anything that begins with SQL, like "SqlHelper," is associated
w/ MS SQL Server. Therefore, it won't work w/ MS Access (JET) db
engine. My guess is you need to use the ODBC or the OLEDB name space to
set up a connection (try the System.Data.OleDb.OleDbConnection classes
first).

OleDbConnection cn = new OleDbConnection();
cn.Provider = "Microsoft.Jet.OLEDB.4.0";

For better info you may want to try the
microsoft.public.dotnet.languages.csharp newsgroup.

- --
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQGzSHIechKqOuFEgEQKLoACcDookU90Qh/0KMXMiU2SqZDOCpbEAoPxK
1ds1qR6FLv0vGKbEqeauLsTu
=Izh4
-----END PGP SIGNATURE-----

Nov 12 '05 #2

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

Similar topics

18
by: Rob R. Ainscough | last post by:
MS Visual Studio Ad contained in VS Magazine. Two developers in "hip" clothing diagramming out a huge flow chart on a beach. I could NOT stop laughing at the stupidity of the ad -- "Let your...
19
by: Rob R. Ainscough | last post by:
MS Visual Studio Ad contained in VS Magazine. Two developers in "hip" clothing diagramming out a huge flow chart on a beach. I could NOT stop laughing at the stupidity of the ad -- "Let your...
6
by: Anony Mous | last post by:
Hi, We've got some clients that are concerned about running Postgresql 7.3.4 on a Win2k Server box, alongside MS SQL Server. I've been running pg on my XP machines for a long time now (with...
2
by: =?Utf-8?B?QW50aG9ueSBSb2RyaWd1ZXosIERCQQ==?= | last post by:
Hi! I downloaded MS Visual Web Developer 2005 Express Edition, MS .NET Framework SDK v2.0, and MS SQL Server 2005. Subsequently, I bought MS Visual Studio 2005 Professional Edition. 1) Are...
1
by: Dr T | last post by:
Hi! I downloaded MS Visual Web Developer 2005 Express Edition, MS .NET Framework SDK v2.0, and MS SQL Server 2005. Subsequently, I bought MS Visual Studio 2005 Professional Edition. 1) Are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.