前台发送字符串给后台,格式为(a,b,c,d),后台将字符串转换成数组遍历后进而更新CheckId...

本文介绍如何使用Newtonsoft.Json库更新数据库中的CheckId字段,并通过代码示例展示了具体实现过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 1 using Newtonsoft.Json;
 2 using System;
 3 using System.Collections.Generic;
 4 using System.Configuration;
 5 using System.Data;
 6 using System.Linq;
 7 using System.Web;
 8 using System.Web.UI;
 9 using System.Web.UI.WebControls;
10 using TL.Common.Util;
11 
12 namespace S_manager
13 {
14     public partial class S_GetCheckMater : System.Web.UI.Page
15     {
16         protected void Page_Load(object sender, EventArgs e)
17         {
18             string matterId = Request.Params["matterid"];
19             char[] chs = { ',' };
20             try
21             {
22                 string[] str = matterId.Split(chs, StringSplitOptions.RemoveEmptyEntries);
23                 string strcnn = ConfigurationManager.ConnectionStrings["conn"].ToString();
24                 SQLHelper sqlHelper = new SQLHelper(strcnn);
25                 for (int i = 0; i < str.Length; i++)
26                 {
27 
28        
29                         //更新数据库的CheckId
30                         string sql = "update growup.dbo.S_Matter set CheckId='1' where S_MatterId ='" + str[i] + "'";
31                         DataSet ds_result = sqlHelper.QueryByCmd(sql);
32                         //格式化查询结果
33                         string json = JsonConvert.SerializeObject(ds_result);
34                         //返回给前端
35                         Response.Write(json);
36                 }
37             }
38             catch { }
39 
40         }
41     }
42 }

 

转载于:https://www.cnblogs.com/laresh/p/4988198.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值