无法往 SQLite 数据库文件里写数据。使用SQLiteSpy打开该文件后显示如下错误
![](https://img-blog.csdnimg.cn/img_convert/0b8a554c67dd9137a10974ecd16a048a.png)
上网搜到了这篇博文:SQLite出现database disk image is malformed(11)的处理
把数据库文件修复后,问题解决。现将数据库文件修复步骤总结如下:
方法一:SQLite Tools
1 、下载SQLite Tools
下载地址:http://www.sqlite.org/download.html
下载文件sqlite-tools-win32-x86-3150200.zip
![](https://img-blog.csdnimg.cn/img_convert/ecfb7c6daab467020d3c3255acfa6861.png)
2、解压上面的压缩包,并在命令行模式下进入该目录运行sqlite3.exe
![](https://img-blog.csdnimg.cn/img_convert/03c0df16940cab083c1bd00a5e99f7bd.png)
3、打开损坏的数据库文件
.open d:/CloudPos.db
4、进行检测
PRAGMA integrity_check
5、设置导出文件为tmp.sql
.output d:/tmp.sql
6、将CloudPos.db中的内容以sql方式导出到tmp.sql
.dump
7、创建temp.db数据库
.open d:/temp.db
8、从tmp.sql中导入数据
.read d:/tmp.sql
9、退出
.quit
方法二 SQLite Expert Professional(推荐) 使用SQLite Expert Professional工具提供的repair来修复db文件
![](https://img-blog.csdnimg.cn/img_convert/e184b80c2b6fde855b2ed0630fe8fbb4.png)