Access2007数据库下载地址与AccessHelper
程序员文章站
2022-07-11 11:18:55
链接:https://pan.baidu.com/s/1pLzOlTv0nqSbhzujHZht1w 提取码:1m9l AccessHelper: //Microsoft.ACE.OLEDB.12.0是连接access2007之后的数据库使用的 //Microsoft.Jet.OLEDB.4.0是连 ......
链接:https://pan.baidu.com/s/1plzoltv0nqsbhzujhzht1w
提取码:1m9l
accesshelper:
using system; using system.collections.generic; using system.data; using system.data.oledb; using system.linq; using system.text; namespace accessireaderdemo { public class accesshelper { string str = @"provider=microsoft.jet.oledb.4.0; data source=f:\邯钢工作计划\物理站\华龙冲击\cbddata2018.mdb"; private static string str; public accesshelper(string _connstr) { str = _connstr; } public static dataset excedataset(string sql, oledbparameter[] parm = null, commandtype type = commandtype.text) { using (oledbconnection conn = new oledbconnection(str)) { using (oledbcommand cmd = new oledbcommand(sql, conn)) { if (parm != null) cmd.parameters.addrange(parm); oledbdataadapter abs = new oledbdataadapter(cmd); dataset set = new dataset(); conn.open(); abs.fill(set); return set; } } } /// <summary> /// reader /// </summary> /// <param name="sql"></param> /// <param name="parm"></param> /// <param name="type"></param> /// <returns></returns> public static oledbdatareader reader(string sql, oledbparameter[] parm = null, commandtype type = commandtype.text) { oledbconnection conn = new oledbconnection(str); oledbcommand cmd = new oledbcommand(sql, conn); if (parm != null) cmd.parameters.addrange(parm); conn.open(); oledbdatareader reader = null; try { reader = cmd.executereader(commandbehavior.closeconnection); } catch (exception e) { throw; } return reader; } /// <summary> /// 查询首行首列 /// </summary> /// <param name="sql"></param> /// <param name="parm"></param> /// <param name="type"></param> /// <returns></returns> public static object excescale(string sql, oledbparameter[] parm = null, commandtype type = commandtype.text) { using (oledbconnection conn = new oledbconnection(str)) { using (oledbcommand cmd = new oledbcommand(sql, conn)) { if (parm != null) cmd.parameters.addrange(parm); cmd.commandtype = type; conn.open(); return cmd.executescalar(); } } } /// <summary> /// 几行受影响 /// </summary> /// <param name="sql"></param> /// <param name="parm"></param> /// <param name="type"></param> /// <returns></returns> public static int excequery(string sql, oledbparameter[] parm = null, commandtype type = commandtype.text) { using (oledbconnection conn = new oledbconnection(str)) { using (oledbcommand cmd = new oledbcommand(sql, conn)) { if (parm != null) cmd.parameters.addrange(parm); cmd.commandtype = type; conn.open(); return cmd.executenonquery(); } } } } }
//microsoft.ace.oledb.12.0是连接access2007之后的数据库使用的
//microsoft.jet.oledb.4.0是连接access2003等数据库使用的。
上一篇: Python去除字符串两端空格的方法
下一篇: 第一眼看完之后不吃了
推荐阅读
-
MySQL提供与Linux绑定的数据库下载_MySQL
-
各种Python库安装包下载地址与安装过程详细介绍(Windows版)
-
VS2008简体中文版安装序列号与下载地址
-
oracle与mysql的视频教程下载地址分享
-
Visual Studio 2012 Ultimate旗舰版下载地址与序列号
-
oracle与mysql的视频教程下载地址分享
-
Windows 8.1 with Update MSDN简体/繁体中文原版下载地址与安装密匙
-
怎么区分WinRAR 5.50无广告版与有广告版?两者对比介绍(附下载地址)
-
微力同步Linux版怎么使用?微力同步Linux版使用详细教程与下载地址
-
Access2007数据库下载地址与AccessHelper