473,666 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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={Micros oft Access Driver (*.mdb)}; DBQ=" + DBFilePath;

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

//SqlHelper is the class in the Microsoft Application Blocks
SqlHelper.Execu teNonQuery( str_1, CommandType.Tex t, 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 5343
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={Micros oft Access Driver (*.mdb)}; DBQ=" + DBFilePath;

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

//SqlHelper is the class in the Microsoft Application Blocks
SqlHelper.Execu teNonQuery( str_1, CommandType.Tex t, 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.Ole Db.OleDbConnect ion classes
first).

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

For better info you may want to try the
microsoft.publi c.dotnet.langua ges.csharp newsgroup.

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

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

iQA/AwUBQGzSHIechKq OuFEgEQKLoACcDo okU90Qh/0KMXMiU2SqZDOCp bEAoPxK
1ds1qR6FLv0vGKb EqeauLsTu
=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
2248
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 ideas run free"....only to be washed up by the waves when the tide comes in -- this is exactly so so so Microsoft. Re-invent the dev tools every 3-5 years in the name of progress and hope developers don't notice -- good revenue generation for MS,...
19
1308
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 ideas run free"....only to be washed up by the waves when the tide comes in -- this is exactly so so so Microsoft. Re-invent the dev tools every 3-5 years in the name of progress and hope developers don't notice -- good revenue generation for MS,...
6
2042
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 cygwin) and never had any sort of problem. The db is fast and stable. Does anyone have any experience that would give some weight to our client's concerns? Would there be any potential conflict between the postmaster and MS SQL Server? Your...
2
1490
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 both the MS Visual Web Developer 2005 Express Edition and the the MS Visual Studio 2005 Professional Edition used to develop .ASP Web pages? 2) Do I have to uninstall any of the software downloaded before I can
1
2498
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 both the MS Visual Web Developer 2005 Express Edition and the MS Visual Studio 2005 Professional Edition used to develop .ASP applications?
0
8448
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8783
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8552
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8640
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6198
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2773
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.