Game Development Reference
In-Depth Information
using System;
using System.Data;
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);
OleDbDataAdapter adapter = new OleDbDataAdapter(“SELECT * FROM YourTable”,
connection);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, “YourTable”);
MessageBox.Show((string)dataSet.Tables[“YourTable”].Rows[0][“SomeTextColumn”]);
This example only shows the select, but after any sort of editing, you can call the
following method to persist your changes back to the database.
adapter.Update(dataSet);
Working with XML
Before showing how to load an XML document, we should first define a simple
XML document that we can load (Books.xml).
<?xml version='1.0'?>
<!— This file represents a fragment of a book store inventory database —>
<bookstore>
<book genre=”autobiography” publicationdate=”1981” ISBN=”1-861003-11-0”>
<title>The Autobiography of Benjamin Franklin</title>
<author>
<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>
</author>
<price>8.99</price>
</book>
<book genre=”novel” publicationdate=”1967” ISBN=”0-201-63361-2”>
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
Search Nedrilad ::




Custom Search