Exemple #1
0
 partial void DeleteExperiment(Experiment instance);
Exemple #2
0
 partial void InsertExperiment(Experiment instance);
Exemple #3
0
 partial void UpdateExperiment(Experiment instance);
Exemple #4
0
        //public void TryCreateTable()
        //{
        //    using (SqlConnection con = new SqlConnection(connectionString))
        //    {
        //        con.Open();
        //        try
        //        {
        //            using (SqlCommand command = new SqlCommand(
        //            "CREATE TABLE Experiments (Date TEXT, ExID TEXT, Name TEXT)", con))
        //            {
        //                command.ExecuteNonQuery();
        //            }
        //        }
        //        catch
        //        {
        //            Console.WriteLine("Table not created.");
        //            //throw new Exception();
        //        }
        //    }
        //}
        public void InsertLog(DateTime date, int exID, string name)
        {
            var ex = new Experiment();
            ex.Date = date;
            ex.ExID = exID;
            ex.Username = name;
            using (var db = new AP439DBDataContext())
            {
                db.Experiments.InsertOnSubmit(ex);
                db.SubmitChanges();
            }

            //using (SqlConnection con = new SqlConnection(connectionString))
            //{
            //    con.Open();
            //    DataTable t = con.GetSchema();
            //    try

            //    {
            //        using (SqlCommand command = new SqlCommand(
            //        "INSERT INTO Experiments(Date,ExID,Name) VALUES(@Date, @ExID, @Name)", con))
            //        {
            //            command.Parameters.Add(new SqlParameter("Date", date));
            //            command.Parameters.Add(new SqlParameter("ExID", exID));
            //            command.Parameters.Add(new SqlParameter("Name", name));
            //            command.ExecuteNonQuery();
            //        }
            //    }
            //    catch(Exception e)
            //    {
            //        Console.WriteLine(e);
            //        Console.WriteLine("Can not insert.");
            //        //throw new Exception();
            //    }
            //}
        }