public string CreateMahasiswa(Mahasiswa mhs) { string msg = "GAGAL"; SqlConnection sqlcon = new SqlConnection("Data Source=LAPTOP-54NOARJ3;Initial Catalog=\"TI UMY\";Persist Security Info=True;User ID=sa;Password=123"); string query = String.Format("insert into dbo.Mahasiswa values ('{0}', '{1}', '{2}', '{3}')", mhs.nama, mhs.nim, mhs.prodi, mhs.angkatan); SqlCommand sqlcom = new SqlCommand(query, sqlcon); try { sqlcon.Open(); Console.WriteLine(query); sqlcom.ExecuteNonQuery(); sqlcon.Close(); msg = "Sukses"; } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(query); msg = "GAGAL"; } return(msg); }