All pastes #38597 Raw Edit

Someone

public text v1 · immutable
#38597 ·published 2006-01-25 21:46 UTC
rendered paste body
using System;
using System.Collections;
using System.Data.OleDb;

namespace ShiningMain.Member
{
	/// <summary>
	/// Summary description for CGuestbook.
	/// </summary>
	public class CGuestbook
	{
		public CGuestbook()
		{
			//
			// TODO: Add constructor logic here
			//
		}
		public static ArrayList getGuestbook()
		{
			ArrayList GB = new ArrayList();
			try
			{
				DataLayer.connect();
				DataLayer.connection.Open();

				OleDbCommand aCommand = new OleDbCommand("select * from tblGuestbook", DataLayer.connection);
				OleDbDataReader aReader = aCommand.ExecuteReader();

				
				if ( aReader.HasRows == true)
				{
					while(aReader.Read())
					{
						Post post = new Post();
						post.Date = aReader["colDate"].ToString();
						post.Message = aReader["colMessage"].ToString();
						
						OleDbCommand cmd = new OleDbCommand("select colUsername from tblUser where Id=" + Convert.ToInt32(aReader["colUserID"]), DataLayer.connection);
						OleDbDataReader read = aCommand.ExecuteReader();
						post.Username = read["colUsername"].ToString();
						read.Close();

						post.Username ="test";
					}
				}
				

				DataLayer.connection.Close();

				return GB;
			}
				
			catch(Exception ex)
			{
				throw ex;
			}
			finally
			{
				DataLayer.connection.Close();		
			}
		}
	}

	public class Post
	{
		private string date, post, user;

		public string Message
		{
			get
			{
				return post;
			}
			set
			{
				post = value;
			}
		}
		public string Date
		{
			get
			{
				return date;
			}
			set
			{
				date = value;
			}
		}
		public string Username
		{
			get
			{
				return user;
			}
			set
			{
				user = value;
			}
		}
	}
}