【发布时间】:2013-07-18 08:31:21
【问题描述】:
我对 C# 很陌生,我正在尝试创建一个 sqlite 数据库连接类。我通过单击我的项目名称 > 添加 > 类创建了一个新的类文件。我在这个文件中有以下代码。
问题是我在SQLiteDataReader 之后的每一行都出现错误
- 如果我将鼠标悬停在
sqlite_conn上,它会显示“...是一个字段,但用作类型” - 如果我将鼠标悬停在
SQLiteConnection上,那么它会说...方法必须有返回类型 - 如果我将鼠标悬停在
("Data Source=database.db;Version=3;New=True;Compress=True;")上,则会显示 Type expected
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Finisar.SQLite;
namespace learningCsharp
{
class database
{
// We use these three SQLite objects:
SQLiteConnection sqlite_conn;
SQLiteCommand sqlite_cmd;
SQLiteDataReader sqlite_datareader;
// Getting error in every lines after this
// create a new database connection:
sqlite_conn = new SQLiteConnection("Data Source=database.db;Version=3;New=True;Compress=True;");
//open the connection:
sqlite_conn.Open();
// create a new SQL command:
sqlite_cmd = sqlite_conn.CreateCommand();
}
}
您能帮我解决这个问题并创建一个有效的 sqlite 数据库连接类吗?
【问题讨论】:
-
您是否尝试过清理并完全重建解决方案?