Exemple #1
0
        // load by name
        public TotalTable loadByName(string dbName, string tableName)
        {
            string          sql   = "select * from totaltable where tablename=@tablename";
            OleDbConnection con   = getCon(dbName);
            OleDbCommand    cmd   = new OleDbCommand(sql, con);
            OleDbParameter  param = new OleDbParameter("@tablename", tableName);

            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);
        }
Exemple #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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }