![]() | CYQ.Data 数据层框架CYQ.Data 是一款由路过秋天创作的支持多数据库应用[Txt,Xml,Access,MSSQL,Oracle,SQLite,MySql]的底层数据库操作类库,使用本类库可以轻松快速开发项目。 |
CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL]
| 快速使用帮助 |
|
|
| #楼主 |
In this section: continue on a content, this section describes MProc class-related operations.
1: MProc execute stored procedure 2: MProc execute SQL operations I:Constructor Method Prototype :
public MProc(object procNamesEnum)
public MProc(object procName, string conn) Description: Constructor and MAction usage of the relevant operating parameters can be MAction. Example 1:Pass stored procedure name //Stored procedure name passed in the default configuration items to take Conn database link MProc proc = new MProc(ProcNames.GetUserList);//Passing through the enumeration Example 2:Pass stored procedure name and custom database link //Into the database a new database link configuration items Conn
MProc proc = new MProc("GetUserList","ChatConn");
//Into the database directly link the new database link string MProc proc = new MProc("GetUserList","Server=.;database=Chat;uid=sa;pwd=xxxxx");
//Multi-use agreement under the name of the database configuration items from ChatConn links MProc proc = new MProc(P_ChatEnum.GetUserList); Example 3:Pass SQL statement Note: Only supported in V1.5 version of the above.
/ / Execute custom SQL statement, the default configuration items database link from Conn
MProc proc = new MProc("select * from Users");
/ / Execute custom SQL statements from the configuration items database link ChatConn MProc proc = new MProc("select * from Users","ChatConn"); II:Parameterization Method Prototype :
public void Set(object paraName, object value)
public void Set(object paraName, object value,SqlDbType sqlDbType) public void Clear() Example 1: //As stored procedures or parameterized SQL statement to set parameters proc.Set(GetUserList.ID, 888);//Enumeration method to pass Example 2: proc.Set(Users.ID, 888,SqlDbType.Int);//More than in the last example of a parameter. Example 3: proc.Clear();//Clear all Set parameters. III:Execute Method Operation Method Prototype :
public MDataTable ExeMDataTable() / / List of query
public int ExeNonQuery() / / Add / Update / Delete public T ExeScalar<T>() / / Return a single value of the first row first column Example 1: MDataTable table = proc.ExeMDataTable();// return MDataTable Example 2: int result = proc.ExeNonQuery();//Insert, update, delete, return the number of rows affected. Example 3: string result = proc.ExeScalar<string>();//Statement is executed, returns the first row first column value. IV:ReturnValue and DataBase Close Method Prototype :
public int ReturnValue public void Close() Example 1: MDataTable table= proc.ExeMDataTable(); int value = proc.ReturnValue;//If the stored procedure is executed, the return value obtained by the total number of records. Example 2:Close manually MProc proc = new MProc(ProcNames.GetList); MDataTable table= proc.ExeMDataTable(); int value = proc.ReturnValue; proc.Close();//Close the database links after the implementation of V:A complete example Example : Examples of use:
Instantiation: using(MProc proc = new MProc(ProcNames.GetList)) {
Add parameters: proc.Set(GetList.ID, 10); Access list: MDataTable table = proc.ExeMDataTable(); Take the return value: int count=proc.ReturnValue;
Bound control: table.Bind(GridView1); } Chinese version of the link:http://www.cyqdata.com/cyqdata/article-detail-415 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]
![]() | |
发表评论
论坛公告
数据框架 CYQ.Data QQ群:
1:6033006
2:90594529
3:129551677
4:113108920
使用本框架进行开发,入门简单,开发效率高,性能优越,更有详尽的API文档,有相关的使用帮助文章、示例文章、更甚有相关的视频教程及辅助工具。
关键还是免费与开源,实在是居家旅行、项目开发、学习研究的必备良品!!!!!!
框架下载:下载中心
帖子搜索
论坛版块
- 平台动态 (17)
- 常见问题及需求反馈 (3)
- 快速使用帮助 (32)
- 框架原理 (14)
- 框架项目案例 (7)
- 商业授权 (2)
- CYQ.DBImport专区 (4)
- CYQ.IISLogsViewer专区 (1)
- 框架技术交流区 (4)
最新帖子
最新评论
- 请问我怎么找不到下载地址
- 崇拜中,试问博主为何敢挑战当今众多<b>数据持久化框架</b>的先驱们?
- 直接用个mongoDB就好了 倒腾来倒腾去
- 首先,感谢下楼主! 我在Oracle导出到SQLite的时候,链接数据库都提示“connect successfully” 然后点击那个“import Go”按钮后,就提示停止工作了。 我的是Win7平台。
- 请问是否可以同时支持多个数据库?比如多个版本的sqlserver,或者同时支持sqlserver 和oracle?
- 秋天大哥,在Winform下使用SQLite,为什么每次在new MAction的时候都提示"数据库字段加载失败!请检查数据库链接及表名(weather)是否存在!"? 我的配置是参考您的指南写的: <appSettings> <add key="SQLiteDbNameForApp" value="Data/tq.db"/> <add key="IsWriteLog" value="true"/> <add key="LogPath" value="Log/"/> </appSettings> <connectionStrings> <add name="Conn" connectionString="Data Source={0}" providerName="System.Data.SQLite"/> </connectionStrings> 辛苦秋天大哥了!
- 云 搞成xml文档不久可以了
- 能否用在winform中?
- 你好,我对你这个挺有兴趣想再了解下信息 请加我MSN:ntwuhaohao@hotmail.com
- 真没看到特色的地方,找了半天,唉

