![]() | CYQ.Data componentsCYQ.Data support multi-database application [Txt,Xml,Access, MSSQL, Oracle,SQLite,MySql], help easily and quickly to develop your project |
CYQ.Data 数据框架 使用篇一 入门指南
Guide |
|
|
| #TopicOwner |
本文针对V5版本进行修改于(2016-07-04) 下面是使用步骤: 一:下载框架DLL[VS上在NuGet搜cyqdata,或者框架下载地址:下载中心] 下载框架后解压出: 1:CYQ.Data.dll和CYQ.Data.Xml(方法注释提示) 2:CYQ.Data.ProjectTool.exe (枚举或实体生成器) 3:API 帮助文档一份 4:更新记录.txt 5:VS集成ProjectTool说明.txt 6:智能提示 如果使用的是SQLite、MySQL、Oracle、Sybase,需要下载相应的驱动DLL放到和CYQ.Data同一目录下。除了Sybase,自行在安装目录下可找到,其它三种,下载CYQ.Data的页面下方都有提供驱动下载。 二:手工下载的,项目添加引用 把 CYQ.Data.dll添加到项目引用中(CYQ.Data.Xml 默认也会被复制引用到Bin目录中) 三:配置数据库链接 web.config[asp.net] 或 app.config[winform] 提示:winform下的app.config需要右键属性,将编绎选项改成内容。
1:MSSQL数据库链接示例 <connectionStrings>
<add name="Conn" connectionString="server=.;database=demo;uid=sa;pwd=123456" providerName="System.Data.SqlClient"/> <connectionStrings> 2:Access 2003数据库链接示例:"{0}"代表根目录 <connectionStrings> <add name="Conn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source={0}App_Data/demo.mdb" providerName="System.Data.OleDb"/> Access 2007或以上版本的链接为:Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0}App_Data/demo.mdb 3:Oracle 数据库链接示例: <connectionStrings> <add name="Conn" connectionString="Provider=MSDAORA;Data Source=demo;User ID=sa;Password=123456;" providerName="System.Data.OracleClient"/> connectionStrings> PS:Oracle支持三种方式: 1:原生的System.Data.OracleClient方式,用以上的链接方式。 2-3:ODP.NET方式,把Oracle.DataAccess.dll(需要安装客户端)或Oracle.ManagedDataAccess.dll(无需安装客户端)放在和CYQ.Data同一目录下即可:链接字符串示例如下: Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT = 1521)))(CONNECT_DATA =(SID = orcl)));User ID=sa;password=123456 4:SQLite 数据库链接示例:"{0}"代表根目录,把System.Data.SQLite.dll放到CYQ.Data同一目录下即可(有区分32位和64位) <connectionStrings> <add name="Conn" connectionString="Data Source={0}App_Data/demo.db;failifmissing=false" providerName="System.Data.SQLite"/> connectionStrings> 5:MySQL数据库链接示例:把MySql.Data.dll放到CYQ.Data同一目录下即可 <connectionStrings> <add name="Conn" connectionString="host=127.0.0.1;Port=3306;Database=mysql;uid=sa;pwd=12346" providerName="MySql.Data.MySqlClient"/> connectionStrings> 6:SyBase:把Sybase.AdoNet2.AseClient.dll放到CYQ.Data同一目录下即可 <connectionStrings> <add name="Conn"connectionString="data source=127.0.0.1;port=5000;database=cyqdata;uid=sa;pwd=123456" providerName="Sybase.Data.AseClient"/> connectionStrings> 6:Txt 文本数据库链接示例: <connectionStrings>
<add name="Conn"connectionString="Txt Path={0}"/> connectionStrings> 7:Xml 文本数据库链接示例: <connectionStrings> <add name="Conn"connectionString="Xml Path={0}"/> connectionStrings> 五:快速上手 试一试1:WinForm、WPF或WebForm数据绑定 using(MAction action=new MAction("表名"))
{
action.Select().Bind(GridView1);//查询所有数据并绑定到GridView中
}
试一试2:数据填充WinForm、WPF或WebForm服务控件 using(MAction action = new MAction("表名")) { if (action.Fill(888))//取主键=888的值 { action.UI.SetToAll(this);//将当前查询的行数据自动绑定到所有控件中。 } } ![]() |
游客[注册][171.221.241.*]2017/7/4 11:12:49 | #14 | |
![]() | 请教博主。我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> |
sedhuawu2011/12/24 21:11:10 | #13 | |
![]() | 秋天大哥,在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> 辛苦秋天大哥了! reply: connectionString="Data Source={0}" ,最新版本的数据库链接已经做了调整,直接使用:connectionString="Data Source={0}Data/tq.db",这么写即可,<add key="SQLiteDbNameForApp" value="Data/tq.db"/>这一行配置可以删除。 |
jiangms[219.133.109.*]2011/7/11 14:18:20 | #12 | |
![]() | 有个问题: 用sql2005数据库代码代码没有问题,用access数据库时出现了报错: 请问是什么原因?access数据库是丛sql2005转化而来的 Error on DataOperator:IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。<br><hr>SQL:<br> select count(*) from shop_type where zone='class1' and parentid=0<hr> 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Exception: Error on DataOperator:IErrorInfo.GetDescription 因 E_FAIL(0x80004005) 而失败。<br><hr>SQL:<br> select count(*) from shop_type where zone='class1' and parentid=0<hr> reply: 这应该是access的问题,可能你的表结构带有系统关键字引起的或表已被独立打开占用的原因。 |
swhhcf2011/6/13 16:37:13 | #9 | |
![]() | *.accdb 无法用辅助工具生成枚举文件,不知下一版本能否改进? reply: 可以生成的,只是设置权限的地方好像换了菜单,具体你在2007上找一下。 |
游客[注册][219.131.182.*]2011/4/14 10:06:48 | #8 | |
![]() | //对UI操作:SetTo与GetFrom action.SetTo(labUserName);//labUserName为Lable控件。 //控件ID约定方式为“三个字母前缀”+字段名.如labUserName,UserName为表的字段名。 ---------------------------------- 如果这种约定规则可以自定义就最好,比如在配置文件里改lable-->对应前缀或简写,可以自定义每一个控件的前缀,如果不设就默认好了,因为都习惯将Lable的简写为lbl开头了,要不就直接写 lableUserName这种还直接 reply: 前面三个母是可以自定义的,随意起的。 |
游客[注册][123.114.36.*]2011/4/8 4:26:31 | #7 | |
![]() | 的确是这样的 控件ID约定方式为“三个字母前缀”+字段名,前缀后面的那个还必须得是【字段名】 |
独行守卫2011/4/7 7:44:21 | #6 | |
![]() | 晕,刚才发留言之后,没数据,我还以为是我这的问题的,结果又多发了几遍,估计刚才的可能是缓存,老大帮忙把那多余的给删了吧! reply: 已经清除,该问题已经处理了,以后应该不会出现回复后过一会再显示的问题。 |
独行守卫2011/4/7 7:40:04 | #5 | |
![]() | 问题: 1、action.SetTo(labUserName); 报错了 ************** 异常文本 ************** System.NullReferenceException: 未将对象引用设置到对象的实例。 在 CYQ.Data.MActionUI.SetTo(Control ct, Object value, Boolean isControlEnabled) 在 CYQ.Data.MActionUI.Set(Object ct, Object value, Boolean isControlEnabled) 在 CYQ.Data.MAction.SetTo(Object control) 用action.SetTo(label1, "value")可以 2、action.Fill(" ") 得到的是多个结果的话,用action.Get<int>(Users.UserName)得到的就只是一个结果 =========================================== action.SetTo();这个是直接给控件赋值的吧,这种写法还是头次看见,总感觉怪怪的! reply: 看一下:试一试2:数据填充,里面的注释说明。 |
游客[注册][124.227.132.*]2011/4/6 19:28:04 | #4 | |
![]() | 不懂性能上会是怎么的?比起NH,AEF,Linq to SQL,XCode,MySoft.Data…… reply: 以上都是传统的ORM框架,独此框架走传统索引方式,性能绝优。 |
游客[注册][58.248.7.*]2011/2/28 0:18:44 | #2 | |
![]() | 请问,关键字“Conn”能否改的 reply: 如果你想改,可采集多数据库项目中的约定形式产生枚举名称就可以了。而约定的名称为“数据库名Conn" |
Post Comment
Bulletin
Article Search
Categories
- Platform for dynamic (20)
- Feedback (9)
- Guide (33)
- Principles (19)
- Project-Case (8)
- Business & Buy (2)
- Technology exchange (45)
New Article
- CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL]
- CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]
- CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value]
- CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select]
- CYQ.Data Components Getting Started Guide [Part 1]
New Comment
- When some one searches for his necessary thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here.
- This is my first time pay a quick visit at here and i am in fact happy to read everthing at alone place.
- I truly appreciate this blog article.Really thank you! Cool.
- please pay a visit to the web sites we follow, like this one particular, as it represents our picks in the web
- Really enjoyed this post.Really thank you!
- Really enjoyed this article.Really looking forward to read more. Great.
- poker bonuses What are the norms of copyright of web content? How as it different from Patent?
- Wow! Thank you! I permanently needed to write on my blog something like that. Can I implement a fragment of your post to my site?
- This website was how do I say it? Relevant!! Finally I ave found something that helped me. Cheers!
- I was reading through some of your content on this internet site and I believe this web site is very informative ! Continue posting.