Search
 
SCRIPT & CODE EXAMPLE
 

SQL

create a sqlite database c#

SQLiteConnection.CreateFile("MyDatabase.sqlite");

SQLiteConnection m_dbConnection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
m_dbConnection.Open();

string sql = "create table highscores (name varchar(20), score int)";

SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();

sql = "insert into highscores (name, score) values ('Me', 9001)";

command = new SQLiteCommand(sql, m_dbConnection);
command.ExecuteNonQuery();

m_dbConnection.Close();
Comment

Create SQLite Db and table using C#

/// 09/09/2022 Mahesh Kumar Yadav. <br/>
/// <summary>
/// Create Db and Table 
/// </summary>
/// <param name="path"></param>
private void CreateSqLiteDb(string path)
{
    SQLiteConnection.CreateFile(path);

    _connectionString = "Data Source=" + path;
    var mDbConnection = new SQLiteConnection(_connectionString);
    using (mDbConnection)
    {
        mDbConnection.Open();
        const string createTableStatement =
            "CREATE TABLE `Entities` ( `SN` INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, `ID` TEXT NOT NULL, `Name` TEXT NOT NULL, `OwnerID` TEXT, `IsGroup` INTEGER, `Status` TEXT, `Properties` TEXT, `Email` TEXT, `FirstName` TEXT, `LastName` TEXT, `AssociatedUsersOrGroups` TEXT, `GroupID` TEXT);";
        var command = new SQLiteCommand(createTableStatement, mDbConnection);
        command.ExecuteNonQuery();
        mDbConnection.Close();
    }
}
Comment

PREVIOUS NEXT
Code Example
Sql :: oracle list datafiles 
Sql :: oracle sql pad left zeros 
Sql :: sql pagination oracle 
Sql :: how to test for sql injection 
Sql :: postgres show databases 
Sql :: sql server select first day of previous year 
Sql :: create view in sql 
Sql :: SELECT exists sql 
Sql :: python pandas df to postgres json table 
Sql :: mysql current time 
Sql :: delete all value query 
Sql :: mysql union 
Sql :: SQL Server lock table example 
Sql :: sql check duplicate value in column 
Sql :: sql left characters 
Sql :: oracle apex view logs 
Sql :: How to check if the column exists in sql table 
Sql :: oracle difference between two dates in years 
Sql :: delete database mysql command 
Sql :: json extract 
Sql :: version and edition of SQL Server Database Engine 
Sql :: pyspark sql row get value 
Sql :: convert multiple columns to rows in sql server 
Sql :: query to count the number of rows in a table in sqlalchemy 
Sql :: postgres user permissions 
Sql :: com.mysql.cj.exceptions.InvalidConnectionAttributeException more than one time zone. You must configure either the server or JD value if you want to utilize time zone support. 
Sql :: postgres top 10 
Sql :: sql period overlap 
Sql :: login phpmyadmin without password 
Sql :: delete row by id mysql 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =