Example #1
0
        public string CreateMahasiswa(Mahasiswa mhs)
        {
            string     msg   = "GAGAL";
            string     query = String.Format("insert into dbo.Mahasiswa values ('{0}','{1}','{2}','{3}')", mhs.nim, mhs.nama, mhs.prodi, mhs.angkatan);
            SqlCommand cmd   = new SqlCommand(query, con);

            try
            {
                con.Open();
                Console.WriteLine(query);
                cmd.ExecuteNonQuery();
                con.Close();
                msg = "Sukses";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(query);
                msg = "GAGAL";
            }


            return(msg);
        }