Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.SQLite;
- using System.IO;
- namespace PyCharm
- {
- class Database
- {
- public SQLiteConnection Connect;
- public string connectionString { get; set; }
- string connection;
- //Создаем подключение к базе
- public void getconnection()
- {
- connection = @"Data Source=Database.db; Version=3";
- connectionString = connection;
- }
- //Создаем базу
- public Database()
- {
- //проверка есть ли такая база
- if (!File.Exists("./Database.db"))
- {
- SQLiteConnection.CreateFile("Database.db");
- getconnection();
- using (SQLiteConnection con=new SQLiteConnection(connection))
- {
- SQLiteCommand command = new SQLiteCommand();
- con.Open();
- string query = @"CREATE TABLE LOGIN(Username nvarchar(25),Password nvarchar(25))";
- command.CommandText = query;
- command.Connection = con;
- command.ExecuteNonQuery();
- //закрываем подключение
- con.Close();
- }
- }
- else
- {
- return;
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment