简单的传参查询并转化为json

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text; namespace Maticsoft.Web.guanlian
{
public partial class guanlian : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int start = int.Parse(Request.QueryString["start"]);
int over = int.Parse(Request.QueryString["over"]); Maticsoft.BLL.guanlian bll = new Maticsoft.BLL.guanlian();
DataSet dataSet = bll.GetListByPage("", "id", start, over);
DataTable dt = dataSet.Tables[0]; StringBuilder Json = new StringBuilder(); //if (string.IsNullOrEmpty(jsonName))
// jsonName = dt.TableName;
Json.Append("{\"list\":[");
if (dt.Rows.Count > )
{
for (int i = ; i < dt.Rows.Count; i++)
{
Json.Append("{");
for (int j = ; j < dt.Columns.Count; j++)
{
Type type = dt.Rows[i][j].GetType();
Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + dt.Rows[i][j].ToString() + "\"");
if (j < dt.Columns.Count - )
{
Json.Append(",");
}
}
Json.Append("}");
if (i < dt.Rows.Count - )
{
Json.Append(",");
}
}
}
Json.Append("]}");
// return Json.ToString();
Response.Write(Json.ToString());
}
}
} 简单的sql查询 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using LTP.Accounts; namespace Maticsoft.Web.guanlian
{
public partial class guanlian : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//int start = int.Parse(Request.QueryString["start"]);
//int over = int.Parse(Request.QueryString["over"]); //Maticsoft.BLL.guanlian bll = new Maticsoft.BLL.guanlian();
//DataSet dataSet = bll.GetListByPage("", "id", start, over); string sql = "select * from guanlian"; DataSet dataSet = DbHelperSQL.Query(sql); DataTable dt = dataSet.Tables[0]; StringBuilder Json = new StringBuilder(); //if (string.IsNullOrEmpty(jsonName))
// jsonName = dt.TableName;
Json.Append("{\"list\":[");
if (dt.Rows.Count > )
{
for (int i = ; i < dt.Rows.Count; i++)
{
Json.Append("{");
for (int j = ; j < dt.Columns.Count; j++)
{
Type type = dt.Rows[i][j].GetType();
Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + dt.Rows[i][j].ToString() + "\"");
if (j < dt.Columns.Count - )
{
Json.Append(",");
}
}
Json.Append("}");
if (i < dt.Rows.Count - )
{
Json.Append(",");
}
}
}
Json.Append("]}");
// return Json.ToString();
Response.Write(Json.ToString());
}
}
} 简单的sql语句加传参 using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using LTP.Accounts; namespace Maticsoft.Web.guanlian
{
public partial class guanlian : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//int start = int.Parse(Request.QueryString["start"]);
//int over = int.Parse(Request.QueryString["over"]);
string user = Request.QueryString["user"]; //Maticsoft.BLL.guanlian bll = new Maticsoft.BLL.guanlian();
//DataSet dataSet = bll.GetListByPage("", "id", start, over); string sql = "select * from guanlian where uer = '"+user+"' "; DataSet dataSet = DbHelperSQL.Query(sql);
DataTable dt = dataSet.Tables[0]; StringBuilder Json = new StringBuilder(); //if (string.IsNullOrEmpty(jsonName))
// jsonName = dt.TableName;
Json.Append("{\"list\":[");
if (dt.Rows.Count > )
{
for (int i = ; i < dt.Rows.Count; i++)
{
Json.Append("{");
for (int j = ; j < dt.Columns.Count; j++)
{
Type type = dt.Rows[i][j].GetType();
Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + dt.Rows[i][j].ToString() + "\"");
if (j < dt.Columns.Count - )
{
Json.Append(",");
}
}
Json.Append("}");
if (i < dt.Rows.Count - )
{
Json.Append(",");
}
}
}
Json.Append("]}");
// return Json.ToString();
Response.Write(Json.ToString());
}
}
}

简单的传参添加

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using LTP.Accounts; namespace Maticsoft.Web.guanlian
{
public partial class guanlian : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//int start = int.Parse(Request.QueryString["start"]);
//int over = int.Parse(Request.QueryString["over"]); //Maticsoft.BLL.guanlian bll = new Maticsoft.BLL.guanlian();
//DataSet dataSet = bll.GetListByPage("", "id", start, over); //string sql = "delete from guanlian where uer = '"+user+"' ";
//DataSet dataSet = DbHelperSQL.Query(sql);
// DataTable dt = dataSet.Tables[0];
//StringBuilder Json = new StringBuilder(); string uer = Request.QueryString["uer"];
string goup = Request.QueryString["goup"];
string visty = Request.QueryString["visty"]; Maticsoft.Model.guanlian txl = new Model.guanlian();
Maticsoft.BLL.guanlian bll = new BLL.guanlian(); txl.uer = uer;
txl.goup = goup;
txl.visty = visty; if (bll.Add(txl) > 0)//使用bll的添加方法
{
Response.Write("{\"result\":\"0\"}");
}
else
{
Response.Write("{\"result\":\"1\"}");
} //if (string.IsNullOrEmpty(jsonName))
// jsonName = dt.TableName;
//Json.Append("{\"list\":[");
//if (dt.Rows.Count > 0)
//{
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// Json.Append("{");
// for (int j = 0; j < dt.Columns.Count; j++)
// {
// Type type = dt.Rows[i][j].GetType();
// Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + dt.Rows[i][j].ToString() + "\"");
// if (j < dt.Columns.Count - 1)
// {
// Json.Append(",");
// }
// }
// Json.Append("}");
// if (i < dt.Rows.Count - 1)
// {
// Json.Append(",");
// }
// }
//}
//Json.Append("]}");
//// return Json.ToString();
//Response.Write(Json.ToString());
}
}
}

sql加传参删除

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using LTP.Accounts; namespace Maticsoft.Web.guanlian
{
public partial class guanlian : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//int start = int.Parse(Request.QueryString["start"]);
//int over = int.Parse(Request.QueryString["over"]); //Maticsoft.BLL.guanlian bll = new Maticsoft.BLL.guanlian();
//DataSet dataSet = bll.GetListByPage("", "id", start, over); //string sql = "delete from guanlian where uer = '"+user+"' ";
//DataSet dataSet = DbHelperSQL.Query(sql);
// DataTable dt = dataSet.Tables[0];
//StringBuilder Json = new StringBuilder(); string uer = Request.QueryString["uer"];
//string goup = Request.QueryString["goup"];
//string visty = Request.QueryString["visty"]; //Maticsoft.Model.guanlian txl = new Model.guanlian();
//Maticsoft.BLL.guanlian bll = new BLL.guanlian(); //txl.uer = uer;
//txl.goup = goup;
//txl.visty = visty; string sql = "delete from guanlian where uer = '"+uer+"' ";
int rows = DbHelperSQL.ExecuteSql(sql.ToString(), ""); //DataTable dt = dataSet.Tables[0]; //StringBuilder Json = new StringBuilder(); if (rows > 0)//使用bll的添加方法
{
Response.Write("{\"result\":\"0\"}");
}
else
{
Response.Write("{\"result\":\"1\"}");
} //if (string.IsNullOrEmpty(jsonName))
// jsonName = dt.TableName;
//Json.Append("{\"list\":[");
//if (dt.Rows.Count > 0)
//{
// for (int i = 0; i < dt.Rows.Count; i++)
// {
// Json.Append("{");
// for (int j = 0; j < dt.Columns.Count; j++)
// {
// Type type = dt.Rows[i][j].GetType();
// Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + "\"" + dt.Rows[i][j].ToString() + "\"");
// if (j < dt.Columns.Count - 1)
// {
// Json.Append(",");
// }
// }
// Json.Append("}");
// if (i < dt.Rows.Count - 1)
// {
// Json.Append(",");
// }
// }
//}
//Json.Append("]}");
//// return Json.ToString();
//Response.Write(Json.ToString());
}
}
}

发送json-简单的传参查询和简单的sql查询的更多相关文章

  1. Flutter路由的跳转、动画与传参(最简单)

    跳转 命名路由 在文件构建时先设置路由参数: new MaterialApp( // 代码 routes: { "secondPage":(BuildContext context ...

  2. Atitit oodbms的查询,面向对象的sql查询jpa jpql hql

    Atitit oodbms的查询,面向对象的sql查询jpa jpql hql 1.1. 标准API历史1 1.2. JPA定义了独特的JPQL(Java Persistence Query Lang ...

  3. 视图查询的数据和sql查询的数据不一样

    视图查询的数据和sql查询的数据不一样. 手动刷新视图 exec sp_refreshview  视图名称

  4. Ajax之Json对象序列化传参

    前端部分:传入参数 "groupObject" : jsonString //对象序列化传参 var projectGroup = {}; projectGroup["i ...

  5. (25)ASP.NET Core EF查询(复杂查询运算符、原生SQL查询、异步查询)

    1.复杂查询运算符 在生产场景中,我们经常用到LINQ运算符进行查询获取数据,现在我们就来了解下生产场景经常出现几种复杂查询运算符. 1.1联接(INNER JOIN) 借助LINQ Join运算符, ...

  6. 数据库查询性能 LinqDB vs Sql查询

    使用LinqDB查询Sqlite数据库数据,不管是大数据还是少量的数据,感觉特别耗时,尤其是首次查询 一个含有2.7万条数据的数据表 首次查询: 查询2.7万条数据,耗时1s 查询指定的1条数据,也要 ...

  7. javascript闭包传参就这么简单

    var query = (function (a) { return a; })('fx'); alert(query);

  8. lua(简单的传参)

    #include <iostream> #include <string.h> extern "C" { /*头文件lua.h定义了Lua提供的基础函数,包 ...

  9. 关于同时查询父子名称的SQL查询语句的写法 id name parentId parentName .

    parentid是1就是id为1的公司的子公司 如图 查询出所有的信息后 由于我要呈现的是parentName 不是parentId所以想问下SQL语句怎么写 谢谢啦~~:) 解法: SELECT s ...

随机推荐

  1. java类与对象_成员变量和局部变量区别

    成员变量和局部变量:1.成员变量:再类中定义,用来描述对象将要有什么.2.局部变量:在类的方法中定义,在方法中临时保存数据.区别:1.作用域不同:  局部:仅限于定义它的方法  成员:整个类中都是可见 ...

  2. Core Data NSAttribute Type 数据类型

    一:使用Core Data 的可用数据类型 NSAttributeType Defines the possible types of NSAttributeType properties. Thes ...

  3. webDriver API——第6部分Locate elements By

    These are the attributes which can be used to locate elements. See the Locating Elements chapter for ...

  4. CXF 调用方式——动态创建客户端(调用稳定版本号为2.7.18)

    今天用动态创建客户端的方式调用webservice,报了这样一个错: 2017-01-05 20:51:46,029 DEBUG main org.apache.cxf.common.logging. ...

  5. Python vs Ruby: 谁是最好的 web 开发语言?

    Python 和 Ruby 都是目前用来开发 websites.web-based apps 和 web services 的流行编程语言之一. 这两种语言在许多方面有相似之处.它们都是高级的面向对象 ...

  6. 电子商务(电销)平台中用户模块(User)数据库设计明细(转载)

    电子商务(电销)平台中用户模块(User)数据库设计明细 以下是自己在电子商务系统设计中的订单模块的数据库设计经验总结,而今发表出来一起分享,如有不当,欢迎跟帖讨论~ 用户基础表(user_base) ...

  7. mac svn 命令

    https://www.cnblogs.com/luckythan/p/4478706.html http://blog.csdn.net/aizhiqiang2/article/details/53 ...

  8. mmcm 和pll

    这个2个有什么区别啊 mmcm 和pll?  1.DCM实际上就是一个DLL,可以对输入时钟进行相位移动,补偿,产生倍频和分频时钟,但是5以及以后的产品不用了.2.PLL相对于DCM,除了不能相移时钟 ...

  9. boost thread

    #include <cassert> #include <iostream> #include <boost/ref.hpp> #include <boost ...

  10. Source Insight 项目简单使用说明

    SI(Source Insight) 是我一直写代码的好伙伴, 相信这强大的软件也是广大程序猿编写软件的利器. 正所谓" 工欲善其事, 必先利其器", 我们要学会利用这款软件. 先 ...