Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2004, 12:25 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default using access database in C#

how do i use access database in C#

 
Old March 18th, 2004, 03:58 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It is a very hard question to answer, or rather it is a very abstract question. However take a look at these classes...

OleDbCommand
OleDbDataReader

The OleDbDataReader is a lightweight class (stream) for reading data from the database. There are lots of other classes.

I have used the following connection string...

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[databaseFilename]

Here is a small fragment of code you can use...

Code:
command = new OleDbCommand();        
command.Connection = new OleDbConnection(connectionString);
command.CommandText = sql;
try
{
   command.Connection.Open();
   reader = command.ExecuteReader();
}
catch(OleDbException e)
{
   throw new Exception(e.Message);    
}
Naturally, some declarations come before this. It will give you a reader from which you can read. Besides the above you should study the database features of .NET more throughly since they are quite different from traditional ASP (at least the way I used these). E.g. take a look at how to use stored procedures, data sets etc.

Read about the objects in the MSDN.

Hope it helps

Jacob.

 
Old March 18th, 2004, 06:17 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much!

They are useful for me!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Access database database format itHighway Access 0 February 24th, 2008 06:34 PM
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Remote access to an Access Project Database bright_mulenga Access 0 February 9th, 2006 10:51 AM
Access issues with ASP and a MS Access Database rj_conceptsnrec.com Classic ASP Databases 2 May 19th, 2005 12:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.