Skip to content

Commit

Permalink
fix: add table exists exception catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Qinyouzeng committed Dec 4, 2023
1 parent 1edb818 commit 82291b6
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@ public static void InitTable(bool isLog)
{
var sql = reader.ReadToEnd();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
try
{
cmd.ExecuteNonQuery();
}
catch
{
//table is exists
}
}

path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Data/otel_{name}_data.txt");
using (var dataReader = new StreamReader(path))
{
Expand All @@ -34,11 +42,10 @@ public static void InitTableData(bool isLog)
connection.Open();
using var cmd = connection.CreateCommand();
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Data/otel_{name}_data.txt");
using (var dataReader = new StreamReader(path))
{
var sql = dataReader.ReadToEnd();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();
}
using var dataReader = new StreamReader(path);
var sql = dataReader.ReadToEnd();
cmd.CommandText = sql;
cmd.ExecuteNonQuery();

}
}

0 comments on commit 82291b6

Please sign in to comment.