public string Post(Tb_LSP tblsp) { try { string query = @" INSERT INTO [LSPdb].[dbo].[Tb_LSP] ([Nomer_Lisensi] ,[NPSN] ,[Status_Lisensi_LSP] ,[Berlaku_Sampai]) VALUES" + " ('" + tblsp.Nomer_Lisensi + "','" + tblsp.NPSN + "','" + tblsp.Status_Lisensi_LSP + "','" + tblsp.Berlaku_Sampai + "')"; 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); } }
public string Put(Tb_LSP tblsp) { try { string query = @"UPDATE [LSPdb].[dbo].[Tb_LSP] SET " + " ,[NPSN] = '" + tblsp.NPSN + "'" + " ,[Status_Lisensi_LSP] = '" + tblsp.Status_Lisensi_LSP + "'" + " ,[Berlaku_Sampai] = '" + tblsp.Berlaku_Sampai + "'" + " WHERE [Nomer_Lisensi] = '" + tblsp.Nomer_Lisensi + "'"; 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); } }