July 10, 2009

dria o

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

namespace detabes
{
    class Student
    {
        OleDbConnection cn = new OleDbConnection(
                @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Students Account\Desktop\sean\detabes.mdb");

    

        private int _id;
        /// <summary>
        /// primary key
        /// </summary>
        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private string  _lastName;
        /// <summary>
        /// lastname lang ni
        /// </summary>
        public string LastName
        {
            get { return _lastName; }
            set { _lastName = value; }
        }

        private string _firstName;
        /// <summary>
        /// firstname lang ni
        /// </summary>
        public string FirstName
        {
            get { return _firstName; }
            set { _firstName = value; }
        }

        private string _middleName;
        /// <summary>
        /// middlename lang ni
        /// </summary>
        public string MiddleName
        {
            get { return _middleName; }
            set { _middleName = value; }
        }

        public bool add()
        {
            try
            {
                this._firstName = string.Empty;
                this._middleName = string.Empty;
                this._lastName = string.Empty;
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        public void Connect()
        {
           try
            {                
                if (cn.State == ConnectionState.Open)
                cn.Close();
                cn.Open();
                /*MessageBox.Show("Connection Success");
                OleDbCommand cmd = new OleDbCommand("Select * from Student", cn);
                OleDbDataAdapter da = new OleDbDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                grdData.DataSource = dt;*/
                

            }

              

            catch (Exception ex)
            {
                throw new Exception("Unable to connect to the database. \n" + ex.Message);
                //MessageBox.Show("Connection Failed." + ex.Message);
            }

            

        }
        public DataTable GetStudentData()
        {
            OleDbCommand cmd =
                new OleDbCommand("select * from Student", cn);
            OleDbDataAdapter da = new OleDbDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            return dt;
        }
    }
}

2 Comments »

The URI to TrackBack this entry is: http://seansome.blogsome.com/2009/07/10/dria-o/trackback/

  1. http://www.daniweb.com/forums/thread190555.html

    Comment by sean — August 24, 2009 @ 2:01 pm

  2. itemId
    itemName
    itemDescription
    quantity
    sellerPrice
    retailerPrice
    supplierId
    branchId

    Comment by test — September 25, 2009 @ 2:07 pm

RSS feed for comments on this post.

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>



Anti-spam measure: please retype the above text into the box provided.