Skip to content

Commit b04359d

Browse files
committed
error check on DB write
1 parent fc4a282 commit b04359d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Software/C#/freETarget/StorageController.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,11 +239,17 @@ public void storeSession(Session session) {
239239
string controlString = getControlString(session);
240240
cmd.Parameters.AddWithValue("@hash", GetMd5Hash(controlString));
241241

242-
cmd.Prepare();
242+
try {
243+
cmd.Prepare();
243244

244-
cmd.ExecuteNonQuery();
245-
con.Close();
246-
Console.WriteLine("Session saved");
245+
cmd.ExecuteNonQuery();
246+
247+
Console.WriteLine("Session saved");
248+
} catch(Exception ex){
249+
MessageBox.Show("Error saving session to the database. Make sure you have write access to the folder." + Environment.NewLine + ex.Message, "Error writing to DB", MessageBoxButtons.OK, MessageBoxIcon.Error);
250+
} finally {
251+
con.Close();
252+
}
247253
}
248254

249255
public string getControlString(Session session) {

0 commit comments

Comments
 (0)