Game Development Reference
In-Depth Information
using System;
using System.Data.OleDb;
using System.Data.Common;
using System.Windows.Forms;
string connectionString
= @”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\YourDB.mdb”;
OleDbConnection connection = new OleDbConnection(connectionString);
OleDbCommand command = new OleDbCommand(“SELECT * FROM YourTable”, connection);
connection.Open();
OleDbDataReader reader = null;
try
{
command.ExecuteReader();
while (reader.Read())
{
MessageBox.Show((string)reader[“SomeTextColumn”]);
}
}
catch (OleDbException exception)
{
// ... Handle database exceptions here
}
finally
{
if (reader != null)
reader.Close();
if (connection != null)
connection.Close();
}
Working with a DataAdapter
The following example shows how to select rows from an Access database file, fill a
DataSet with the rows, and display a message box for the first row in SomeTextColumn .
Search Nedrilad ::




Custom Search