< Programmeren in ASP.net 2.0 N-Tier Tutorial < Data Access Laag

C#-code: "MessageDataAccessor.cs"

using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Text;

using MessageBoard.Common.DataSets;

namespace MessageBoard.DataAccess
{
	public class MessageDataAccessor: DataAccessor
	{
		public MessageDataSet GetMessages()
		{
			string sql = "SELECT * FROM Message";
			DbCommand cmd = Database.CreateSqlCommand(sql);
			MessageDataSet data = new MessageDataSet();
			Database.LoadDataSet(cmd, data, "Message");
			return data;
		}

		protected override DbCommand GetInsertCommand()
		{
			throw new Exception("The method or operation is not implemented.");
		}

		protected override DbCommand GetUpdateCommand()
		{
			throw new Exception("The method or operation is not implemented.");
		}

		protected override DbCommand GetDeleteCommand()
		{
			throw new Exception("The method or operation is not implemented.");
		}
	}
}
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.