我用PHP创建了一个带表的数据库.我是通过以下方式完成的:
<?php
$db = new SQLiteDatabase("test.db");
unset($db);
$db = sqlite_open("test.db");
sqlite_query($db,"create table students (names char(255))");
sqlite_close($db);
?>
Run Code Online (Sandbox Code Playgroud)
从命令行执行我的PHP文件后:"php test.php"我在我的目录中得到一个名为"test.db"的新文件(这就是我想要的).在命令行中,我键入"sqlite3 test.db".这样我就进入了sqlite命令行会话.然后,使用sqlite3,我输入".tables"(我想检查新数据库是否包含它应该包含的表).结果我得到:
Error: file is encrypted or is not a database
Run Code Online (Sandbox Code Playgroud)
所以,它不起作用.有人知道这个问题吗?预先感谢您的任何帮助.
我正在使用sqlite数据库的Windows应用程序.net 2.0,我的连接字符串保持在app.config之类
<connectionStrings>
<add name="SQLiteDB"
connectionString="Data Source=|DataDirectory|database.s3db;version=3;password=mypassword;"
providerName="System.Data.Sqlite"/>
</connectionStrings>
Run Code Online (Sandbox Code Playgroud)
在连接字符串中,我已将密码定义为"mypassword",如果我删除此密码一切正常,但是当我使用密码子句时,它给出了connection.open()语法错误
File opened that is not a database file
file is encrypted or is not a database
Run Code Online (Sandbox Code Playgroud)
我在网上搜索并发现了一些版本问题,但我只使用版本3,因为我在连接字符串中说明我也尝试删除"版本= 3"但问题仍然是相同的.
我是第一次这样做,它的解决方案是什么?