Added code ensuring that there is not a crash upon creation of sqlite database.
This commit is contained in:
1 parent
9c6ea08221
commit
41667d9e0b
3 files changed
+10
-2
No files matched your search
@@ -16,6 +16,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.0.5" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.0.5" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.5" />
|
||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.5" />
|
||||
|
||||
@@ -36,9 +36,15 @@ public class CoinDatabase {
|
||||
}
|
||||
|
||||
private SQLiteConnection CreateConnection() {
|
||||
// Create a connection.
|
||||
// Check if database exists.
|
||||
if (!System.IO.File.Exists("%USERPROFILE%\\coin_collection")) {
|
||||
// Create the database.
|
||||
SQLiteConnection.CreateFile("%USERPROFILE%\\coin_collection");
|
||||
}
|
||||
|
||||
// Create a connection to the database.
|
||||
SQLiteConnection connection =
|
||||
new SQLiteConnection("DataSource=C:\\Users\\lvas4\\coin_collection");
|
||||
new SQLiteConnection("DataSource=%USERPROFILE%\\coin_collection");
|
||||
|
||||
// Open the connection.
|
||||
try {
|
||||
|
||||
@@ -12,5 +12,6 @@ Global
|
||||
{887D7BD0-3E71-435D-82CD-3DAF3187D056}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{887D7BD0-3E71-435D-82CD-3DAF3187D056}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{887D7BD0-3E71-435D-82CD-3DAF3187D056}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{887D7BD0-3E71-435D-82CD-3DAF3187D056}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Reference in new issue
Block a user