Ejemplo n.º 1
0
 private static void NewCmd()
 {
     Con = new SqlConnection();
     Con.ConnectionString = CDataAccess.GetConStr();
     Cmd            = new SqlCommand();
     Cmd.Connection = Con;
 }
Ejemplo n.º 2
0
        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(); }
        }