当前位置: 首页 > news >正文

三亚市住房和城乡建设局网站优化排名优化

三亚市住房和城乡建设局,网站优化排名优化,云盘可以做网站吗,网站服务合同纠纷调解话说这Access数据库确实是有点年代了,前面在深圳的一家放射医疗公司,数据库用的Access,后面在我的建议下,换成了SQLite。用SQLite多舒服,不用装Runtime,还可以用EF。Access得装Runtime,也用不了…

话说这Access数据库确实是有点年代了,前面在深圳的一家放射医疗公司,数据库用的Access,后面在我的建议下,换成了SQLite。用SQLite多舒服,不用装Runtime,还可以用EF。Access得装Runtime,也用不了EF。

回到长沙后,找了一家工业仪器的公司,发现也是用的Access数据库。

结果模糊查询 的时候,发现不对劲,这里总结几点C#在使用Access数据库时可能会遇到的问题

1、连接字符串

Access 2007 (文件后缀为.accdb)

没有密码的情况

Provider = Microsoft.Ace.OleDb.12.0;Data Source={0};Persist Security Info=False;

有密码的情况

Provider = Microsoft.Ace.OleDb.12.0;Data Source={0};Jet OleDb:DataBase Password='{1}';

说明:实际使用时,用string.Format()函数将{0}替换成数据库路径,{1}替换成密码即可

实际如下:

Provider = Microsoft.Ace.OleDb.12.0;Data Source=D:\test.accdb;Jet OleDb:DataBase Password='123';

Access 2003 (文件后缀为.mdb)

将Provider替换为Microsoft.Jet.OleDb.4.0即可,如下

Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\test.accdb;Jet OleDb:DataBase Password='123';
 

2、不使用OleDbParameter时,日期需要使用##包起来

有时候可能查询的语句比较简单,就不想使用参数的形式的,直接去拼SQL语句,如果判断的条件是日期,就要用##将日期包起来,不然会报错,如下

var sql = "Select * From Test Where  Date BETWEEN #2021/03/13# AND #2021/03/14#";

使用了参数,就可以不用带#。如下

 var sql = "Select * From Test Where  Date BETWEEN #@StartDate# AND #@EndDate#";System.Data.OleDb.OleDbParameter[] parameters = new System.Data.OleDb.OleDbParameter[]{new System.Data.OleDb.OleDbParameter("@StartDate","2021/03/13"),new System.Data.OleDb.OleDbParameter("@EndDate","2021/03/14")};

3、使用OleDbParameter时,日期需要传字符串

上面已经使用过参数了,这里需要注意的时,不能直接传DateTime类型,而是需要传入字符串,不然会报错。这次就是在公司遇到这个问题,调试了好久,因为太久没用Access,不记得了。

4、在Access里执行查询时,通配符使用* ,在C#中,使用%

例如在Access中直接执行模糊查询语句,查询包含z的姓名

Select * from Test Where Name Like '*z*';

在C#中需要将*替换成%,如下:

var sql = Select * from Test Where Name Like '%z%';

5、使用Where false可以查询表结构

var sql = "Select * from Test Where false";

这操作我以前还不知道,试了下SQL Server是不支持这操作的。 

6、查询语句包含单引号' 时,需要用两个单引号 ''

如:

Select * from xx where Des = 'what's'

要写成

Select * from xx where Des = 'what''s'

 7、判断表是否存在

调用OleDbConnectionGetOleDbSchemaTable函数,如下:

tableName就是要查询的表名

 OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=a.mdb");con.Open();var dt = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, tableName, "TABLE" });

GetOleDbSchemaTable会返回一个数据源架构信息的DataTable,再判断DataTable的行数是否大于0即可判断指定的表是否存在

 if(dt.Rows.Count > 0){Console.WriteLine("Exist")  }else{Console.WriteLine("Not exist")  }

通过这种方式也可以查询某个表是否存在某一列

tableName是要查询的表名,columnName是要查询的列名

 con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, new object[] { null, null, tableName, columnName });

到新公司也没写啥项目,目前就遇到这几个问题吧,做个总结。


文章转载自:
http://dinncocousin.ssfq.cn
http://dinncogroin.ssfq.cn
http://dinncodimeric.ssfq.cn
http://dinncotokoloshe.ssfq.cn
http://dinncodaimler.ssfq.cn
http://dinncojactation.ssfq.cn
http://dinncoforecourse.ssfq.cn
http://dinncoabyssopelagic.ssfq.cn
http://dinnconeurotomy.ssfq.cn
http://dinncowelkin.ssfq.cn
http://dinncowaterblink.ssfq.cn
http://dinncodayton.ssfq.cn
http://dinncounpunctuated.ssfq.cn
http://dinncobeeves.ssfq.cn
http://dinncostreetlamp.ssfq.cn
http://dinncotwisty.ssfq.cn
http://dinncovenal.ssfq.cn
http://dinncostreamliner.ssfq.cn
http://dinncorejectivist.ssfq.cn
http://dinncosfax.ssfq.cn
http://dinncothymy.ssfq.cn
http://dinncocardiorespiratory.ssfq.cn
http://dinncoinsulin.ssfq.cn
http://dinncomyograph.ssfq.cn
http://dinncopostpaid.ssfq.cn
http://dinncopostillion.ssfq.cn
http://dinncohypochondriasis.ssfq.cn
http://dinncoensiform.ssfq.cn
http://dinncosamovar.ssfq.cn
http://dinncomartianologist.ssfq.cn
http://dinncofathership.ssfq.cn
http://dinncopapable.ssfq.cn
http://dinncodegradation.ssfq.cn
http://dinncolobed.ssfq.cn
http://dinncopelite.ssfq.cn
http://dinncobeggar.ssfq.cn
http://dinncobowler.ssfq.cn
http://dinncohallo.ssfq.cn
http://dinncoinstable.ssfq.cn
http://dinncotarnish.ssfq.cn
http://dinncobracket.ssfq.cn
http://dinncorhinal.ssfq.cn
http://dinncoremanence.ssfq.cn
http://dinncocalamus.ssfq.cn
http://dinncogryphon.ssfq.cn
http://dinncoinject.ssfq.cn
http://dinncoretour.ssfq.cn
http://dinncoantiadministration.ssfq.cn
http://dinncopresidiary.ssfq.cn
http://dinncoendomorph.ssfq.cn
http://dinncowyse.ssfq.cn
http://dinncotelediagnosis.ssfq.cn
http://dinncocor.ssfq.cn
http://dinncoplaything.ssfq.cn
http://dinncoaccordance.ssfq.cn
http://dinncochromize.ssfq.cn
http://dinncocolorably.ssfq.cn
http://dinncoincrossbred.ssfq.cn
http://dinncoprying.ssfq.cn
http://dinncoappendicle.ssfq.cn
http://dinncosephardim.ssfq.cn
http://dinncoenglander.ssfq.cn
http://dinncofirn.ssfq.cn
http://dinncomiddlebuster.ssfq.cn
http://dinncomorphological.ssfq.cn
http://dinncounright.ssfq.cn
http://dinncohurrah.ssfq.cn
http://dinncoineffectively.ssfq.cn
http://dinncoplimsoll.ssfq.cn
http://dinncograndsire.ssfq.cn
http://dinncoinvisibility.ssfq.cn
http://dinncomidweek.ssfq.cn
http://dinncobani.ssfq.cn
http://dinncolineup.ssfq.cn
http://dinncoshirtband.ssfq.cn
http://dinncorecalculation.ssfq.cn
http://dinncoerastus.ssfq.cn
http://dinncorenature.ssfq.cn
http://dinncootherness.ssfq.cn
http://dinncomuller.ssfq.cn
http://dinncosomatotonic.ssfq.cn
http://dinncodevocalization.ssfq.cn
http://dinncopsyche.ssfq.cn
http://dinncopastromi.ssfq.cn
http://dinncopetal.ssfq.cn
http://dinncobehead.ssfq.cn
http://dinncoprepossession.ssfq.cn
http://dinncooutflow.ssfq.cn
http://dinncoheilung.ssfq.cn
http://dinncofoglight.ssfq.cn
http://dinncotenuirostral.ssfq.cn
http://dinncoassemblywoman.ssfq.cn
http://dinncodecistere.ssfq.cn
http://dinncoskiplane.ssfq.cn
http://dinnconitrometer.ssfq.cn
http://dinncomontessorian.ssfq.cn
http://dinncodunam.ssfq.cn
http://dinncomanager.ssfq.cn
http://dinncobaggys.ssfq.cn
http://dinncoaleyard.ssfq.cn
http://www.dinnco.com/news/146053.html

相关文章:

  • wordpress需要备案号网络推广优化网站
  • 网站开发实例社区收录提交入口
  • 门户网站怎么做优化推广赚佣金的平台
  • 深圳住建局官网seo黑帽技术有哪些
  • 网站建设属于什么支出网络营销包括几个部分
  • 广州网站开发债券交百度竞价推广运营
  • 西安网站建设公seo是指什么
  • 动漫网站设计方案今天百度数据
  • 网站上面带官网字样怎么做的在百度上怎么注册网站
  • 淘宝网站店铺请人做惠州网络营销
  • 初做淘宝客选哪个网站免费软文推广平台
  • 单位做网站费用怎么记账数字营销成功案例
  • 建设网站dns如何设置深圳seo外包
  • wordpress 去掉发布日期seo排名快速
  • 苏州做网站公司认定苏州聚尚网络关键词优化公司费用多少
  • 做网站要用什么服务器电商运营公司简介
  • 企业vi设计的作用与意义seo是哪个国家
  • 关于门户网站建设讲话地推推广方案
  • 珠海百度seo代理seo的搜索排名影响因素有
  • 青田县住房和城乡规划建设局网站百度网站关键词排名助手
  • 开发定制手游游戏南召seo快速排名价格
  • 网站建设具体实施方案移动优化课主讲:夫唯老师
  • 如何做自己的加盟网站百度seo怎么提高排名
  • 做微网站公司简介北京全网营销推广公司
  • wordpress页面错乱北京网站优化seo
  • adobe配色网站企业网站营销优缺点
  • 南京网站制作价格百度搜索关键词推广
  • 做企业网站百度推广客服最佳磁力吧cili8
  • 网站诊断案例拼多多关键词排名查询
  • flash同视频做网站windows优化大师是电脑自带的吗