private static void NewCmd() { Con = new SqlConnection(); Con.ConnectionString = CDataAccess.GetConStr(); Cmd = new SqlCommand(); Cmd.Connection = Con; }
public static void AddLog(string Table, string Message) { SqlConnection Con = new SqlConnection(CDataAccess.GetConStr()); SqlCommand Cmd = new SqlCommand(); Cmd.Connection = Con; Cmd.CommandText = "insert into TblLog (Date, Message, Tbl, UserID) values (@Date, @Message, @Tbl, @UserID)"; Cmd.Parameters.AddWithValue("@Date", DateTime.Now); Cmd.Parameters.AddWithValue("@Message", Message); Cmd.Parameters.AddWithValue("@Tbl", Table); Cmd.Parameters.AddWithValue("@UserID", Program.UserID); try { Con.Open(); Cmd.ExecuteNonQuery(); } catch (Exception) { } finally { Con.Close(); } }