CYQ.Data 数据层框架

CYQ.Data 是一款由路过秋天创作的支持多数据库应用[Txt,Xml,Access,MSSQL,Oracle,SQLite,MySql]的底层数据库操作类库,使用本类库可以轻松快速开发项目(QQ群:6033006)。

CYQ.Data Components Getting Started Guide [Part 1]

快速使用帮助 | | | 发表日期 :2011/7/2 16:03:31#楼主  

Download Address : CYQ.Data Tiny Data Components Download Center

Learn how to use :

I:Add CYQ.Data reference to project

II:Configuration database link web.config or app.config

Tip: winform need right under the app.config attributes, for Yi options will change the content.

1:MSSQL Database Link Example

<connectionStrings>
<add name="Conn" connectionString="server=.;database=cyqdata.com;uid=sa;pwd=123456" providerName="System.Data.SqlClient"/>
connectionStrings>

2:Access 2003 Database link example, V4.3 before, winform / web unified with [AccessDbNameForWeb]

<appSettings>

<add key="AccessDbNameForWeb" value="App_Data/myspace.mdb" /></appSettings>

<connectionStrings>
<add name="Conn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}" providerName="System.Data.OleDb"/>
connectionStrings>

3:Oracle Database Link Example

<connectionStrings>
<add name="Conn" connectionString="Provider=MSDAORA;Data Source=cyqdata.com;User ID=sa;Password=123456;" providerName="System.Data.OracleClient"/>
connectionStrings>

4:SQLite Database link example, V4.3 before, winform / web unified with [SQLiteDbNameForWeb]

<appSettings>

<add key="SQLiteDbNameForWeb" value="App_Data/myspace.mdb" /></appSettings>

<connectionStrings>
<add name="Conn" connectionString="Data Source={0}" providerName="System.Data.SQLite"/>
connectionStrings>

5:MySQL Database Link Example

<connectionStrings>
<add name="Conn" connectionString="Server=127.0.0.1;Port=1234;Database=mysql;uid=sa;pwd=12346" providerName="MySql.Data.MySqlClient"/>
connectionStrings>

III:Generate a page  stored procedure to the database[This step only applies to MSSQL, Oracle, other database, omit this step, have built-in paging]

1:Way 1, the code created to generate stored procedures, applies only to prior version V4.3 [not included V4.3]

Please out CYQ.Data.SQL.OutPutData, generation, just find the background code execution aspx page:

OutPutData data = new OutPutData();
data.ExeCreateProc(FiledDescriptionType.Sql2005);

2:The second way, using enumeration tool to generate

1:Download the enumeration tool

2:Run: configure link link, click the button to automatically generate stored procedures to complete.

3:Check: go to the appropriate database to see if the stored procedure to generate SelectBase page.

IV:Try coding

1:The original way to write code

Try 1: Data Binding

original :
MAction action = new MAction("TableName");
GridView1.DataSource
=
action.Select();
GridView1.DataBind();
action.Close();
 
Shorthand:
using(MAction action=new MAction("TableName"))
{
    action.Select().Bind(GridView1);
}
 

Try 2: Data fill

 
MAction action = new MAction("TableName");
if (action.Fill(888))//Get id=888 's value

{
     //For UI:SetTo与GetFrom
     action.SetTo(labUserName);
//
labUserName is Lable Control。
     //Control ID may agree to a "three-letter prefix" + field name, such as labUserName, UserName for the table field names. 
     //For No UI:Set 与 Get
     int userName=action.Get("UserName");
     action.Close();
}

2:Add Enum To Write Code

Doubt: the above example a "TableName", "UserName", so knock dead code, or if you modify the table name field is not difficult to find problems?

Answer: One way: to please the CYQ.Data.SQL.OutPutData, generated enumeration, just find a code-behind aspx page

OutPutData data = new OutPutData();
Response.Write(data.OutPutAllTableEnum(TableType.U, FiledDescriptionType.Sql2005,
false));

Operation: a new class called the name of TableNames.cs, to automatically delete all the information generated, leaving a blank, while the output of the enumeration copy and paste the above into it.

Second way: V4.3 version has been removed OutPutData class, auxiliary tools to easily generate enumerate the files.

Then try 1: Data Binding

using(MAction action = new MAction(TableNames.Users))//Use Enum
{
            action.Select().Bind(GridView1);
}

Then try 2: Data fill

 
MAction action = new MAction(TableNames.Users);
if (action.Fill("id=888"))
{
            action.SetTo(labUserName);
            int userName=action.Get<int>(Users.UserName);//Use Enum
            action.Close();
}

Chinese version of the link:http://cyqdata.com/cyqdata/article-detail-411

More tutorials:



新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"
https://royalcbd.com[89.28.10.*]2020/9/29 1:40:59#2
Du2Zdd It was hard It was hard to get a grip on everything, since it was impossible to take in the entire surroundings of scenes.
suba suba[89.28.10.*]2018/12/21 17:33:17#1
BWyT5C Very good article post.Much thanks again. Fantastic.

发表评论

论坛公告

    数据框架 CYQ.Data QQ群:6033006
    使用本框架进行开发,入门简单,开发效率高,性能优越,更有详尽的API文档,有相关的使用帮助文章、示例文章、更甚有相关的视频教程及辅助工具。 关键还是免费与开源,实在是居家旅行、项目开发、学习研究的必备良品!!!!!!


    在线帮助:欢迎联系

帖子搜索