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

小广告推广网站青岛网站建设技术托管

小广告推广网站,青岛网站建设技术托管,中国林业工程建设协会网站,专业h5网站建设教程1,一般的访问方式。 1.1,连接语句。 //sqlite 连接,支持相对位置,也支持绝对位置 Data Source../../Database/cater.db// 连接数据库,FailIfMissingfalse时若文件不存在会自动创建 string connStr "DataSourcetest.db;Vers…

1,一般的访问方式。

1.1,连接语句。
//sqlite 连接,支持相对位置,也支持绝对位置
Data Source=../../Database/cater.db// 连接数据库,FailIfMissing=false时若文件不存在会自动创建
string connStr ="DataSource=test.db;Version=3;Pooling=true;FailIfMissing=false;";
1.2,配置文件设置。
//需在配置文件中进行如下配置否则报错
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
 1.3,常用语法。
//语法:
select * from AlarmHistory
insert into alarmhistory (AlarmDetails,starttime) values ('abc',getdate())
//获取当前时间
select datetime('now')
SELECT datetime('now', 'localtime');
select CURRENT_TIMESTAMP//插入当前时间
insert into alarmhistory (alarmdetails,starttime) values('',datetime('now','localtime'))//查找为null的数据
select * from alarmhistory where StartTime is null//修改表格序号update sqlite_sequence set seq = 0 where name = 'AlarmHistory'//查询表格主键
select * from
pragma_table_info ('ActualData') where pk=1//查询表格是否存在
select exists(  select * from sqlite_master where type='table' and name='ActualData')//删除表格drop table 'ActualData' //获取和设置时间,时间格式只支持类似yyyy-MM-dd这样用-连接的格式,若用/连接则无效
select datetime('2024-08-22 16:23:55')
SELECT datetime('now', 'localtime');
1.4,SQLite访问dll。

https://download.csdn.net/download/lingxiao16888/89914696

2,基于EntityFramework的ORM数据访问。

2.1,安装Nuget包

这部分比较简单,直接Nuget包中下载即可

  1. System.Data.SQLite
  2. System.Data.SQLite.EF6
  3. System.Data.SQLite.LINQ
  4. SQLite.CodeFirst

2.2,配置文件需要进行如下修改。
<?xml version="1.0" encoding="utf-8"?>
<configuration><configSections><!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --><section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /></configSections><startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /></startup><entityFramework><providers><provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /><provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /><provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /></providers></entityFramework><system.data><DbProviderFactories><remove invariant="System.Data.SQLite.EF6" /><add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" /><remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories></system.data>
</configuration>
2.3,应用。
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Data.SQLite;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace ConsoleApp2
{class Program{static void Main(string[] args){MyDbContext context = new MyDbContext("cater.db");var set = context.Set<MemmberType>();var ss = set.FirstOrDefault();foreach (var item in set){Console.WriteLine($"{item.MemTpName} ; {item.MemType} ; {item.MemTpDesc} ; {item.SubBy} ;{item.DelFlag}");}Console.WriteLine("输出完成!");Console.ReadKey();}}class MyDbContext : DbContext{public MyDbContext(string constr) : base(new SQLiteConnection{ConnectionString = new SQLiteConnectionStringBuilder{DataSource = constr,ForeignKeys = true}.ConnectionString}, true){}//如果查询 MemmberType 表,则该属性不能省略public virtual DbSet<MemmberType>  MemmberType { get; set; }}[Table("MemmberType")]//该特性不能省略class MemmberType{[Key]//如果存在主键该特性不能省略[Column("MemType",TypeName ="INT")]public int MemType { get; set; }//[Column("MemTpName")]public string MemTpName { get; set; }[Column("MemTpDesc")]//可使用 Required 特性指定该列不能为空public string MemTpDesc { get; set; }//[Column("DelFlag")]public int DelFlag { get; set; }//[Column("SubBy")]public int SubBy { get; set; }}
}
2.4,效果。

数据库文件数据。

查询结果。

http://www.yayakq.cn/news/291845/

相关文章:

  • 网站空间管理面板网站后台iis配置
  • 专业制作网站公司哪家好医疗器械网站建设
  • 荔浦火车站建设在哪里维持一个素材网站要多少钱
  • 建设摩托车官方网站wordpress 文章 图片 插件
  • 长泰县建设局网站做视频网站怎么备案
  • wordpress 首页静态厦门做网站优化
  • 网站建设公司宝安做二手电脑的网站
  • 网站邮箱代码怎么自己建设网站
  • icp备案添加网站深圳建筑业网
  • 做网站在后台如何添加链接wordpress 微商城模板下载地址
  • 技术网站经营网站如何挣钱
  • 站长工具网站提交布吉附近做网站
  • 做网站 宁波外国网站 dns解析失败
  • 网站设计做什么大学生求职简历模板免费下载
  • 显示网站正在建设中深圳福田区怎么样
  • 团队协同网站开发营销网站建设规划方案
  • 品牌网站建设费wordpress无法发送
  • photoshop做图网站个人主页页面设计制作
  • 天津网络关键词排名seo sem培训
  • 网站开发公司基础产品网站介绍模版
  • 如何更快的让百度收录网站建设部评职称查询网站
  • 贵州省建设银行招聘网站html5做网站的好处
  • 网站seo优化关键词快速排名上首页向客户介绍网站建设
  • 音乐网站用什么语言做网站展示型广告案例解析
  • 凡科建站快车代理登录沈阳妇科医院排名最好的医院
  • 广西住建局官方网站dw网页制作多少钱
  • 济南专业做网站做任务给佣金的网站
  • php网站开发示例代码甘肃网络推广公司
  • 百度识图在线使用外贸seo网站推广
  • 手机和pc合一的网站门户网站html下载