Beispiel #1
0
        public string Put(Tb_Kompetensi_Keahlian tbkk)
        {
            try
            {
                string query = @"UPDATE [dbo].[Tb_Kompetensi Keahlian] SET "
                               + "   ,[Nama_KK] = '" + tbkk.Nama_KK + "'"
                               + "     WHERE [Kode_KK] = '" + tbkk.Kode_KK + "'";

                DataTable table = new DataTable();
                using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LSPdb"].ConnectionString))
                {
                    using (var cmd = new SqlCommand(query, conn))
                    {
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }
                    }
                }

                return("Update Successfully");
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }
Beispiel #2
0
        public string Post(Tb_Kompetensi_Keahlian tbkk)
        {
            try
            {
                string query = @"
                        INSERT INTO [dbo].[Tb_Kompetensi_Keahlian]
                              ([Kode_KK]
                              ,[Nama_KK])
                        VALUES"
                               + "('" + tbkk.Kode_KK + "','" + tbkk.Nama_KK + "')";

                DataTable table = new DataTable();
                using (var conn = new SqlConnection(ConfigurationManager.ConnectionStrings["LSPdb"].ConnectionString))
                {
                    using (var cmd = new SqlCommand(query, conn))
                    {
                        using (var da = new SqlDataAdapter(cmd))
                        {
                            cmd.CommandType = CommandType.Text;
                            da.Fill(table);
                        }
                    }
                }
                return("Insert Successfully");
            }
            catch (Exception err)
            {
                return(err.Message);
            }
        }