Here is my code, btw:
//Copyright (C) 2000 Microsoft Corporation. All rights reserved.
// OleDbSample.cs
// compile with: /r:system.dll /r:system.data.d ll /r:system.xml.dl l
// To build this sample from the command line, use the command:
// csc /r:system.dll /r:system.data.d ll /r:system.xml.dl l oledbsample.cs
using System;
using System.Data;
using System.Data.Ole Db;
using System.Xml.Seri alization;
public class MainClass {
public static void Main ()
{
// Set Access connection and select strings.
// The path to BugTypes.MDB must be changed if you build the sample
// from the command line:
#if USINGPROJECTSYS TEM
string strAccessConn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=..\\..\\ BugTypes.MDB";
#else
string strAccessConn = "Provider=Micro soft.Jet.OLEDB. 4.0;Data
Source=BugTypes .MDB";
#endif
string strAccessSelect = "SELECT * FROM Categories";
// Create the dataset and add the Categories table to it:
DataSet myDataSet = new DataSet();
myDataSet.Table s.Add("Categori es");
// Create Access objects:
OleDbConnection myAccessConn = new OleDbConnection (strAccessConn) ;
OleDbCommand myAccessCommand = new
OleDbCommand(st rAccessSelect,m yAccessConn);
OleDbDataAdapte r myDataAdapter = new OleDbDataAdapte r(myAccessComma nd);
myAccessConn.Op en();
try
{
myDataAdapter.F ill(myDataSet," Categories");
}
finally
{
myAccessConn.Cl ose();
}
try
{
// A dataset can contain multiple tables, so let's get them all
// into an array:
DataTableCollec tion dta = myDataSet.Table s;
foreach (DataTable dt in dta)
{
Console.WriteLi ne("Found data table {0}", dt.TableName);
}
// The next two lines show two different ways you can get the
// count of tables in a dataset:
Console.WriteLi ne("{0} tables in data set", myDataSet.Table s.Count);
Console.WriteLi ne("{0} tables in data set", dta.Count);
// The next several lines show how to get information on a
// specific table by name from the dataset:
Console.WriteLi ne("{0} rows in Categories table",
myDataSet.Table s["Categories "].Rows.Count);
// The column info is automatically fetched from the database, so
// we can read it here:
Console.WriteLi ne("{0} columns in Categories table",
myDataSet.Table s["Categories "].Columns.Count) ;
DataColumnColle ction drc = myDataSet.Table s["Categories "].Columns;
int i = 0;
foreach (DataColumn dc in drc)
{
// Print the column subscript, then the column's name and its
// data type:
Console.WriteLi ne("Column name[{0}] is {1}, of type {2}",i++ ,
dc.ColumnName, dc.DataType);
}
DataRowCollecti on dra = myDataSet.Table s["Categories "].Rows;
foreach (DataRow dr in dra)
{
// Print the CategoryID as a subscript, then the CategoryName:
Console.WriteLi ne("CategoryNam e[{0}] is {1}", dr[0], dr[1]);
}
}
catch (Exception e)
{
Console.WriteLi ne("Oooops. Caught an exception:\n{0} ", e.Message);
}
}
}
"Roy Gourgi" <ro***@videotro n.ca> wrote in message
news:Aw******** *************@w eber.videotron. net...
Hi,
I am using VS.NET 2003 and I have made a connection to a MS Access
database using the Server Explorer. Is this connection permanent, meaning
that it will be there every time I reopen my program. Furthermore, how do
I add, delete, find, update a record?
TIA
Roy