Esempio n. 1
0
        // add
        public void add(string dbName,TotalTable form )
        {
            string sql = "insert into totaltable(tablename) values(@tablename)";
            OleDbConnection con  = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbParameter param = new OleDbParameter("@tablename",form.Tablename);
            cmd.Parameters.Add(param);

            cmd.ExecuteNonQuery();

            // close the con
            closeAll(con, cmd, null);
        }
Esempio n. 2
0
        //  search all
        public List<TotalTable> findAll(string dbName)
        {
            string sql = "select * from totaltable";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);

            OleDbDataReader reader = cmd.ExecuteReader();
            List<TotalTable> list = new List<TotalTable>();
            while(reader.Read()) {
                TotalTable bean = new TotalTable();

                bean.Id = reader.GetInt32(0);
                bean.Tablename = reader.GetString(1);

                list.Add(bean);
            }
            if (list.Count() <= 0) {
                return null;
            }

            return list;
        }
Esempio n. 3
0
        // load
        public TotalTable load(string dbName,int id)
        {
            string sql = "select * from totaltable where id=@id";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbParameter param = new OleDbParameter("@id",id);
            cmd.Parameters.Add(param);

            OleDbDataReader reader = cmd.ExecuteReader();
            TotalTable bean = null;
            if (reader.Read()) {
                bean = new TotalTable();

                bean.Id = reader.GetInt32(0);
                bean.Tablename = reader.GetString(1);
            }

            // close the con
            closeAll(con, cmd, reader);

            return bean;
        }
Esempio n. 4
0
        // update
        public void update(string dbName,TotalTable form)
        {
            string sql = "update totaltable set tablename=@tablename where id=@id";
            OleDbConnection con = getCon(dbName);
            OleDbCommand cmd = new OleDbCommand(sql, con);
            OleDbParameter[] param = {new OleDbParameter("@tablename",form.Tablename),new OleDbParameter("@id",form.Id) };
            cmd.Parameters.AddRange(param);

            cmd.ExecuteNonQuery();

            // close the con
            closeAll(con,cmd,null);
        }