using System; using System.Data; using System.Data.OleDb; using Microsoft.Data.Odbc; using System.Collections; namespace DataLibrary { public class Book { public Book() { } public ArrayList GetAll() { ArrayList output = new ArrayList(); OleDbConnection myConnection = new OleDbConnection("Provider=MySQLProv;Location=localhost;Data Source=dbarticle;User=root;Password=;"); myConnection.Open(); OleDbCommand myCommand = myConnection.CreateCommand(); myCommand.CommandText = "SELECT Book_id, title, author_id, publisher_id FROM Book;"; OleDbDataReader myReader = myCommand.ExecuteReader(); try { while (myReader.Read()) { Hashtable row = new Hashtable(); row[ "book_id" ] = myReader.GetInt32( 0 ); row[ "title" ] = myReader.GetString( 1 ); row[ "author_id" ] = myReader.GetInt32( 2 ); row[ "publisher_id" ] = myReader.GetInt32( 3 ); output.Add( row ); } } finally { myReader.Close(); } myConnection.Close(); return output; } } }