CYQ.Data 数据层框架CYQ.Data 是一款由路过秋天创作的支持多数据库应用[Txt,Xml,Access,MSSQL,Oracle,SQLite,MySql]的底层数据库操作类库,使用本类库可以轻松快速开发项目(QQ群:6033006)。 |
CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]
快速使用帮助 |
|
|
| #楼主 |
In this section: continue on a content, all of this section to Insert , delete, Update , related operations.
1: Insert method to add data
2: Delete method to delete data 3: Update method to update data 一:Insert Operation Method Prototype:
public bool Insert()
public bool Insert(bool autoSetValue) public bool Insert(bool autoSetValue, InsertOption option) Example 1: using(MAction action = new MAction(TableNames.Users))
{
action.Set(Users.NickName, "cyqdata");//Non-UI Set Value action.GetFrom(txtUserName)//UI Set Value
if(action.Insert())
{
int id=action.Get<int>(Users.ID);//Back into the post-primary key ID
} } Example 2: using(MAction action = new MAction(TableNames.Users))
{
action.Set(Users.NickName, "cyqdata");
action.GetFrom(txtUserName) action.SetAutoPrefix("txt"); //Control prefix setting, you can set more than one action.Insert(true);//In addition to the assigned set, the other table fields automatically from Request ["txt field"] in value. } Another: SetAutoPrefix automatic prefix method Method Prototype : public void SetAutoPrefix(string autoPrefix, params string[] otherPrefix) More than one prefix can be set as an example: action.SetAutoPrefix("txt","ddl","lab"); Example 3: using(MAction action = new MAction(TableNames.Users))
{
action.Set(Users.NickName, "cyqdata");
action.GetFrom(txtUserName)
action.Insert(false,InsertOption.ID);//After insertion, have only been increased from ID } InsertOption Enumeration Description: /// <summary>
/// Option to insert the return value of the data /// </summary> public enum InsertOption { /// <summary> /// Use this: insert data [MSSQL will return ID, other databases will not return ID] /// </summary> None, /// <summary> /// Use this: Insert data returned ID. /// </summary> ID, /// <summary> /// Use this: insert data, based on the query to return ID after filling the data line. [Default] /// </summary> Fill, } 二:Delete Operation Method Prototype :
public bool Delete() public bool Delete(object where) Example 1: using(MAction action = new MAction(TableNames.Users))
{ action.Set(Users.ID, 1); action.Delete(); } Example 2: using(MAction action = new MAction(TableNames.Users))
{ action.Delete("id=1 or UserName='cyqdata"); } 三:Update Operation Method Prototype :
public bool Update() public bool Update(object where) public bool Update(object where, bool AutoSetValue) Example 1: using(MAction action = new MAction(TableNames.Users))
Example 2: using(MAction action = new MAction(TableNames.Users))
Example 3: using(MAction action = new MAction(TableNames.Users))
{
action.Set(Users.NickName, "cyqdata");
action.GetFrom(txtUserName);
action.SetAutoPrefix("txt"); action.Update("id=1",true); } Chinese version of the link:http://www.cyqdata.com/cyqdata/article-detail-414 More tutorials: 1:CYQ.Data Components Getting Started Guide [Part 1] 2:CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select] 3:CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value] 4:CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update] 5:CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL] |
love anal[37.233.27.*]2017/3/5 6:23:35 | #8 | |
GuLerm What degree could I get involving music AND creative writing? |
Learn More[37.233.27.*]2017/2/1 23:10:43 | #7 | |
aK26av Spot on with this write-up, I really suppose this website needs much more consideration. I?ll most likely be again to read much more, thanks for that info. |
fiverr crorkservice[37.233.27.*]2015/11/9 19:46:22 | #6 | |
FlNlki Very nice post. I just stumbled upon your blog and wished to say that I have really enjoyed browsing your blog posts. In any case I will be subscribing to your feed and I hope you write again soon! |
crorkz matz[37.233.27.*]2014/8/6 8:16:15 | #5 | |
sGENtC Hey, thanks for the blog.Really thank you! Will read on... |
crorkz matz[37.233.27.*]2014/8/6 5:26:23 | #4 | |
mlh330 Really enjoyed this article.Much thanks again. Great. |
cheap backlinks[37.233.27.*]2014/7/19 6:46:55 | #3 | |
PYcAzl Im obliged for the blog article. Keep writing. |
the best seo service[192.162.19.*]2013/9/8 16:16:11 | #2 | |
lSb5nn Im grateful for the article post.Thanks Again. Fantastic. |
seo service[192.162.19.*]2013/9/6 6:46:07 | #1 | |
c1DKfM I appreciate you sharing this blog article.Much thanks again. |
发表评论
论坛公告
帖子搜索
最新帖子
最新评论
- 请教博主。我mysql的提示 V5.7.7.4 MySql.xxxx:check the tablename "tbl_site_info" is exist? error:ExeDataReader():Expression #1 of ORDER BY clause is not in SELECT list, references column 'information_schema.s1.ORDINAL_POSITION' which is not in SELECT list; this is incompatible with DISTINCT 配置如下: <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="Conn" connectionString="host=192.168.3.101;Port=3306;Database=xxxxx;uid=root;pwd=2017" providerName="MySql.Data.MySqlClient"/> </connectionStrings> </configuration>
- 查询语句有点问题,软件启动时查询语句可以从数据库查询出数据,软件一直运行时无论怎么修改数据库,查询出来的还是老数据,不知道是为什么
- 我语句中用到了union all而且两个查询都有查询条件,action.select总是不成功,不知道有没有什么好的解决办法,谢谢
- 大神,如果我想通过一个对象(从数据映射过来的)要插入的话,我需要遍历字段然后每个set一下吗?有没有更好的方法??
- 真心好用,想问下秋天直接拼写sql怕注入吗
- V4.5后,好多方法都改变了,求来个新的日志帮助
- 請問大神V5源碼要多少錢 我是和交流過的
- 楼主,,从数据库里查出来并绑定datagridview,但是显示的都是数据库里的英文名,怎么改??好纠结啊这个。。。。
- 我想问一下,主从表添加怎样处理
- 10年就过了!!!!