I am very new to C#, I am trying to create a sqlite database connection class. I have created a new class file by clicking on my project name> Add > Class. I have the following code in this file.
The problem is I am getting error in every lines after SQLiteDataReader
- If I hover over
sqlite_conn
then it says '... is a field but is used like a type' - if I hover over
SQLiteConnection
then it says ... method must have a return type - If I hover over
("Data Source=database.db;Version=3;New=True;Compress=True;")
then it says 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();
}
}
Could you please help me to solve this problem and create a working sqlite database connection class?