Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void CreateDatabase()
- {
- using SQLiteConnection conn = new(_dbPath);
- using SQLiteCommand createShiftsTable = conn.CreateCommand();
- using SQLiteCommand createGasTable = conn.CreateCommand();
- using SQLiteCommand createMaintenanceTable = conn.CreateCommand();
- conn.Open();
- createShiftsTable.CommandText = @"CREATE TABLE IF NOT EXISTS
- [shifts] (
- [Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- [Date] VARCHAR(2048),
- [StartTime] VARCHAR(2048),
- [EndTime] VARCHAR(2048),
- [StartMileage] INTEGER,
- [EndMileage] INTEGER,
- [Earnings] REAL)";
- createGasTable.CommandText = @"CREATE TABLE IF NOT EXISTS
- [gas] (
- [Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- [Date] VARCHAR(2048),
- [Amount] REAL,
- [Location] VARCHAR(2048))";
- createMaintenanceTable.CommandText = @"CREATE TABLE IF NOT EXISTS
- [maintenance] (
- [Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- [Date] VARCHAR(2048),
- [Amount] REAL,
- [Location] VARCHAR(2048),
- [Notes] VARCHAR(2048))";
- try
- {
- createShiftsTable.ExecuteNonQuery();
- try
- {
- createGasTable.ExecuteNonQuery();
- try
- {
- createMaintenanceTable.ExecuteNonQuery();
- }
- catch (Exception ex)
- {
- ColorPrint.Write(ex.Message, ConsoleColor.Red);
- }
- }
- catch (Exception ex)
- {
- ColorPrint.Write(ex.Message, ConsoleColor.Red);
- }
- }
- catch (Exception ex)
- {
- ColorPrint.Write(ex.Message, ConsoleColor.Red);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment