public string CreateMahasiswa(Mahasiswa mhs) { string msg = "Gagal"; sqlConnection = new SqlConnection(connectionString); 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, sqlConnection); try { sqlConnection.Open(); Console.WriteLine(query); cmd.ExecuteNonQuery(); sqlConnection.Close(); msg = "Sukses"; } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(query); } return(msg); }