Esempio n. 1
0
        public DataTable GetSkyTaskList(SkyZenTask task)
        {
            DataTable datatable = new DataTable();
            string    sql       = "select * from tb_sys_task where id=@id";

            using (MySqlConnection conn = new MySqlConnection(connName))
            {
                MySqlParameter[] map = new MySqlParameter[] {
                    new MySqlParameter("@id", task.id)
                };
                MySqlCommand cmd = new MySqlCommand(sql, conn);
                cmd.Parameters.AddRange(map);
                conn.Open();
                try
                {
                    //READ方式连接
                    //MySqlDataReader read = MySqlHelper.ExecuteReader(conn, sql, map);
                    //MySqlDataAdapter方式
                    MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
                    adapter.Fill(datatable);
                }
                catch (Exception e)
                {
                    throw;
                }
                return(datatable);
            }
        }
        public ActionResult index2()
        {
            SkyZenTask task = skyZenTaskService.GetSkyTaskList(new SkyZenTask()
            {
                id = 10086
            });

            return(View(task));
        }
Esempio n. 3
0
        public SkyZenTask GetSkyTaskList(SkyZenTask task)
        {
            SkyZenTask skyZenTask = new SkyZenTask();
            DataTable  datatable  = new DataTable();

            try
            {
                datatable  = skyZenTaskDBService.GetSkyTaskList(task);
                skyZenTask = DataTableToModel.ToSingleModel <SkyZenTask>(datatable);
            }
            catch (Exception e)
            {
                throw e;
            }
            return(skyZenTask);
        }