Asp.net中使用Sqlite数据库的方法
发布时间:2024-01-18 03:14:45
实际运用中当我用SqliteAdmin以及SQLite Expert Professional 2软件新建Sqlite数据库的时候在ASP.NET中是无法运用的,老是报错:文件不是一个合法的数据库。后来采用一种方法,就是直接在ASP.NET里面利用引用入的DLL新建数据库就可以用了。
string datasource = "d:\\test.db"; //数据库文件的地址
System.Data.SQLite.SQLiteConnection.CreateFile(datasource); //产生文件
这样产生出的test.db就可以在asp.net中运用了,此时你即使用SqliteAdmin以及SQLite Expert Professional 2软件打开它在里面建表都不影响它的使用了。
对Sqlite的操作其实跟Access非常像的,只不过OleDB开头的都变成了SQLite而已…
.NET Framework Data Provider for ODBC
DRIVER=SQLite3 ODBC Driver; Database=mydb.db; LongNames=0; Timeout=1000; NoTXN=0;SyncPragma=NORMAL; StepAPI=0;
This is just one connection string sample for the wrapping OdbcConnection class that calls the underlying ODBC Driver. See respective ODBC driver for more connection strings to use with this class.
SQLite3 ODBC Driver
DRIVER=SQLite3 ODBC Driver; Database=mydb.db; LongNames=0; Timeout=1000; NoTXN=0;SyncPragma=NORMAL; StepAPI=0;
SQLite.NET
Basic(基本的)
Data Source=filename;Version=3;
Using UTF16(使用UTF16编码)
Data Source=filename;Version=3;UseUTF16Encoding=True;
With password(带密码的)
Data Source=filename;Version=3;Password=myPassword;
Using the pre 3.3x database format(使用3.3x前数据库格式)
Data Source=filename;Version=3;Legacy Format=True;
Read only connection(只读连接)
Data Source=filename;Version=3;Read Only=True;
With connection pooling(设置连接池)
Data Source=filename;Version=3;Pooling=False;Max Pool Size=100;
Using DateTime.Ticks as datetime format()
Data Source=filename;Version=3;DateTimeFormat=Ticks;
The default value is ISO8601 which activates the use of the ISO8601 datetime format
Store GUID as text(把Guid作为文本存储,默认是Binary)
Data Source=filename;Version=3;BinaryGUID=False;
如果把Guid作为文本存储需要更多的存储空间
Specify cache size(指定Cache大小)
Data Source=filename;Version=3;Cache Size=2000;
Cache Size 单位是字节
Specify page size(指定页大小)
Data Source=filename;Version=3;Page Size=1024;
Page Size 单位是字节
Disable enlistment in distributed transactions
Data Source=filename;Version=3;Enlist=N;
Disable create database behaviour(禁用创建数据库行为)
Data Source=filename;Version=3;FailIfMissing=True;
默认情况下,如果数据库文件不存在,会自动创建一个新的,使用这个参数,将不会创建,而是抛出异常信息
Limit the size of database(限制数据库大小)
Data Source=filename;Version=3;Max Page Count=5000;
The Max Page Count is measured in pages. This parameter limits the maximum number of pages of the database.
Disable the Journal File (禁用日志回滚)
Data Source=filename;Version=3;Journal Mode=Off;
This one disables the rollback journal entirely.
Persist the Journal File(持久)
Data Source=filename;Version=3;Journal Mode=Persist;
This one blanks and leaves the journal file on disk after a commit. Default behaviour is to delete the Journal File after each commit.
Controling file flushing
Data Source=filename;Version=3;Synchronous=Full;
Full specifies a full flush to take action after each write. Normal is the default value. Off means that the underlying OS flushes I/O's.


猜你喜欢
- 如何制作一个从Access数据库中读取记录的下拉菜单?看看这个例子:<% SQL = "SEL
- 本文实例讲述了Python iter()函数用法。分享给大家供大家参考,具体如下:python中的迭代器用起来非常灵巧,不仅可以迭代序列,也
- vue组件在通信中,无论是子组件向父组件传值还是父组件向子组件传值,他们都有一个共同点就是有中间介质,子向父的介质是自定义事件,父向子的介质
- 前言由于Django是 * 站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,1.
- 为什么使用Python假设我们有这么一项任务:简单测试局域网中的电脑是否连通.这些电脑的ip范围从192.168.0.101到192.168
- 在进行数据抓取时,经常会遇到IP被限制的情况,常见的解决方案是搭建 * 池,或购买IP代理的服务。除此之外,还有一个另外的方法就是使用家里
- 废话不多说,直接上代码吧!# -*- coding: utf-8 -*-import cv2import numpy as np# ----
- 大家好,今天就来说说requests的基础用法。1.准备工作首先呢,我们要确保我们已经之前安装requests库,如果没有安装,可以自行搜索
- 这段时间我一直在说设计需要有层次感,这种层次感可能有很多类型,比如色彩的层次感,或是元素的层次感。当一个设计缺乏层次感的时候页面所表现出来的
- 本文实例讲述了Python决策树之基于信息增益的特征选择。分享给大家供大家参考,具体如下:基于信息增益的特征选取是一种广泛使用在决策树(de
- 什么是 PiniaPinia (西班牙语中的菠萝),本质上依然是一个状态管理的库,用于跨组件、页面进行状态共享.pinia 与 vuex 的
- window.opener 的用法 window.opener 返回的是创建当前窗口的那个窗口的引用,比如点击了a.htm上的一
- 1.建立项目,进入项目文件夹2.初始化ssh key 参见官网指南.(本机生成一对key,public key传到官网sshkey下面)ht
- 今天在mysql官网上下载了mysql-5.7.18-winx64.zip,并解压;然后按https://www.jb51.net/arti
- Go语言实现互斥锁、随机数、time、Listimport ( "container/list"  
- 开发过程中,我们经常会遇到代码回滚的情况。正常人都知道,git 回滚有两大宝:git revertgit reset当我们在本地开发,还未
- 拖拽功能主要是用在让用户做一些自定义的动作,比如拖动排序,弹出框拖动移动等等拖拽的流程动作1、鼠标按下 会触发onmousedown事件2、
- Oblog4.6 ACCESS版转换为UCenterHome1.5的全过程1、 说明:
- 前言,在pytorch中,当服务器上的gpu被占用时,很多时候我们想先用cpu调试下代码,那么就需要进行gpu和cpu的切换。方法1:x.t
- 下面给大家介绍下小程序弹窗禁止页面滚动的效果:在小程序弹窗时,外部页面禁止滚动, 可以在最外部容器设置catchtouchmove但是如果弹