需要引用:Microsoft.SharePoint.Client

ascx:

<h4>CSOM所有表名</h4>
<table>
<tr>
<td></td>
<td>
<asp:Button ID="btn_AllTabel_Select" runat="server" Text="检索" OnClick="btn_AllTabel_Select_Click" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Label ID="lbl_AllTabel_List" runat="server" Text=""></asp:Label></td>
</tr> </table> <h4>CSOM创建表名</h4>
<table>
<tr>
<td>表名:</td>
<td>
<asp:TextBox ID="txt_Tabel" runat="server"></asp:TextBox></td>
<td>
<asp:Label ID="lbl_Notes_cjbm" runat="server" Text=""></asp:Label>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_CreateTabel" runat="server" Text="创建" OnClick="btn_CreateTabel_Click" /></td>
</tr> </table> <h4>CSOM添加数据</h4>
<table>
<tr>
<td>Name:</td>
<td>
<asp:TextBox ID="txt_Name" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Desc:</td>
<td>
<asp:TextBox ID="txt_Desc" runat="server"></asp:TextBox></td>
<td>
<asp:Label ID="lbl_Notes_tjsj" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_Add" runat="server" Text="添加" OnClick="btn_Add_Click" /></td>
</tr> </table> <h4>CSOM查找数据</h4>
<table>
<tr>
<td>Name:</td>
<td>
<asp:TextBox ID="txt_Name_Select" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_Select" runat="server" Text="查找" OnClick="btn_Select_Click" /></td>
</tr> </table> <h4>CSOM修改数据</h4>
<table>
<tr>
<td>Id:</td>
<td>
<asp:TextBox ID="txt_Update_Id" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Name:</td>
<td>
<asp:TextBox ID="txt_Update_Name" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td>Desc:</td>
<td>
<asp:TextBox ID="txt_Update_Desc" runat="server"></asp:TextBox></td>
<td>
<asp:Label ID="lbl_Notes_xfsj" runat="server" Text=""></asp:Label></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_Update" runat="server" Text="修改" OnClick="btn_Update_Click" /></td>
</tr> </table> <h4>CSOM删除数据</h4>
<table>
<tr>
<td>Id:</td>
<td>
<asp:TextBox ID="txt_Delete_Id" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="btn_Delete" runat="server" Text="删除" OnClick="btn_Delete_Click" /></td>
</tr> </table>

cs:

 /// <summary>
/// 创建表名
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_CreateTabel_Click(object sender, EventArgs e)
{
//share point 环境 IP
string ServerClientContext = "http://server-sp:10001/sites/gzzwz01";
//share point 环境 账户
string UserName = "administrator@sharepoint.com.cn";
//share point 环境 密码
string PassWord = "@ronger0506"; ClientContext context = new ClientContext(ServerClientContext);
context.Credentials = new NetworkCredential(UserName, PassWord);
var web = context.Web; //表名
string tableName = "tableName"; if (txt_Tabel.Text.Trim() != "")
{
tableName = txt_Tabel.Text.Trim();
} //表名
ListCollection listct = context.Web.Lists;
context.Load(listct); //加载客户端对象list.RootFolder.Folders
context.ExecuteQuery();
foreach (List list in listct)
{
if (list.Title.Equals(tableName, StringComparison.OrdinalIgnoreCase))
{
lbl_Notes_cjbm.Text = tableName + "表已存在。"; return;
}
} ListCreationInformation listCreationInfo = new ListCreationInformation();
listCreationInfo.Title = tableName;
listCreationInfo.TemplateType = (int)ListTemplateType.GenericList;
List list_Info = web.Lists.Add(listCreationInfo);
list_Info.Description = "New Description";
Field field1 = list_Info.Fields.AddFieldAsXml(
@"<Field Type='Text'
DisplayName='Name'/>",
true, AddFieldOptions.DefaultValue);
Field field2 = list_Info.Fields.AddFieldAsXml(
@"<Field Type='Note'
DisplayName='Desc'/>",
true, AddFieldOptions.DefaultValue);
list_Info.Update();
context.ExecuteQuery();
} /// <summary>
/// 添加数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Add_Click(object sender, EventArgs e)
{
//share point 环境 IP
string ServerClientContext = "http://server-sp:10001/sites/gzzwz01";
//share point 环境 账户
string UserName = "administrator@sharepoint.com.cn";
//share point 环境 密码
string PassWord = "@ronger0506"; ClientContext context = new ClientContext(ServerClientContext);
context.Credentials = new NetworkCredential(UserName, PassWord);
var web = context.Web; string _Tabel = txt_Tabel.Text.Trim();
string _Name = txt_Name.Text.Trim();
string _Desc = txt_Desc.Text.Trim(); var list = web.Lists.GetByTitle(_Tabel); ListItemCreationInformation listItemCI = new ListItemCreationInformation();
ListItem item = list.AddItem(listItemCI); item["Title"] = _Name;
item["Name"] = _Name;
item["Desc"] = _Desc;
item.Update();
context.ExecuteQuery();
} /// <summary>
/// 查找数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Select_Click(object sender, EventArgs e)
{ //share point 环境 IP
string ServerClientContext = "http://server-sp:10001/sites/gzzwz01";
//share point 环境 账户
string UserName = "administrator@sharepoint.com.cn";
//share point 环境 密码
string PassWord = "@ronger0506"; ClientContext context = new ClientContext(ServerClientContext);
context.Credentials = new NetworkCredential(UserName, PassWord);
var web = context.Web; string _Tabel = txt_Tabel.Text.Trim();
string _Name = txt_Name_Select.Text.Trim(); var list = web.Lists.GetByTitle(_Tabel); CamlQuery query = new CamlQuery();
query.ViewXml = string.Format(
@"<View>
<Query>
<Where>
<Eq>
<FieldRef Name='Name' />
<Value Type='Text'>{0}</Value>
</Eq>
</Where>
<OrderBy>
<FieldRef Name='Name' Ascending='FALSE' />
</OrderBy>
</Query>
</View>", _Name);
ListItemCollection items = list.GetItems(query);
context.Load(items); context.ExecuteQuery(); for (int i = ; i < items.Count; i++)
{
txt_Update_Id.Text = items[i].Id.ToString();
txt_Update_Name.Text = items[i]["Name"].ToString();
txt_Update_Desc.Text = items[i]["Desc"].ToString();
}
} /// <summary>
/// 修改数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Update_Click(object sender, EventArgs e)
{ //share point 环境 IP
string ServerClientContext = "http://server-sp:10001/sites/gzzwz01";
//share point 环境 账户
string UserName = "administrator@sharepoint.com.cn";
//share point 环境 密码
string PassWord = "@ronger0506"; ClientContext context = new ClientContext(ServerClientContext);
context.Credentials = new NetworkCredential(UserName, PassWord);
var web = context.Web; string _Tabel = txt_Tabel.Text.Trim();
int _id =Convert.ToInt32(txt_Update_Id.Text);
List table_List = context.Web.Lists.GetByTitle(_Tabel); ListItem listItem = table_List.GetItemById(_id); listItem["Name"] = txt_Update_Name.Text.Trim();
listItem["Desc"] = txt_Update_Desc.Text.Trim();
listItem.Update(); context.ExecuteQuery(); } /// <summary>
/// 删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Delete_Click(object sender, EventArgs e)
{
//share point 环境 IP
string ServerClientContext = "http://server-sp:10001/sites/gzzwz01";
//share point 环境 账户
string UserName = "administrator@sharepoint.com.cn";
//share point 环境 密码
string PassWord = "@ronger0506"; ClientContext context = new ClientContext(ServerClientContext);
context.Credentials = new NetworkCredential(UserName, PassWord);
var web = context.Web; string _Tabel = txt_Tabel.Text.Trim();
int _id = Convert.ToInt32(txt_Delete_Id.Text);
List table_List = context.Web.Lists.GetByTitle(_Tabel); ListItem listItem = table_List.GetItemById(_id); // 删除
listItem.DeleteObject();
context.ExecuteQuery();
} /// <summary>
/// 查询 所有列表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_AllTabel_Select_Click(object sender, EventArgs e)
{
//share point 环境 IP
string ServerClientContext = "http://server-sp:10001/sites/gzzwz01";
//share point 环境 账户
string UserName = "administrator@sharepoint.com.cn";
//share point 环境 密码
string PassWord = "@ronger0506"; ClientContext context = new ClientContext(ServerClientContext);
context.Credentials = new NetworkCredential(UserName, PassWord);
var web = context.Web; context.Load(web.Lists, lists => lists.Include(list => list.Title, list => list.Id));
context.ExecuteQuery(); foreach (List list in web.Lists)
{
lbl_AllTabel_List.Text = lbl_AllTabel_List.Text + list.Title + ",";
} }

share point CSOM 客户端模式 创建表 增删改查的更多相关文章

  1. share point CSOM 客户端模式 创建 list

    /// <summary> /// 创建新的列表 list /// </summary> /// <param name="web"></ ...

  2. Android(java)学习笔记245:ContentProvider使用(银行数据库创建和增删改查的案例)

    1. Android的四大组件: (1)Activity  用户交互的UI界面 (2)Service  后台运行的服务 (3)BroadcastReceiver 广播接收者 (4)ContentPro ...

  3. Android(java)学习笔记189:ContentProvider使用(银行数据库创建和增删改查的案例)

    1. Android的四大组件: (1)Activity  用户交互的UI界面 (2)Service  后台运行的服务 (3)BroadcastReceiver 广播接收者 (4)ContentPro ...

  4. Django框架(八)--单表增删改查,在Python脚本中调用Django环境

    一.数据库连接配置 如果连接的是pycharm默认的Sqlite,不用改动,使用默认配置即可 如果连接mysql,需要在配置文件中的setting中进行配置: 将DATABASES={} 更新为 DA ...

  5. Django框架(九)—— 单表增删改查,在Python脚本中调用Django环境

    目录 单表增删改查,在Python脚本中调用Django环境 一.数据库连接配置 二.orm创建表和字段 三.单表增删改查 1.增加数据 2.删除数据 3.修改数据 4.查询数据 四.在Python脚 ...

  6. GZFramwork数据库层《四》单据主从表增删改查

    同GZFramwork数据库层<三>普通主从表增删改查 不同之处在于:实例 修改为: 直接上效果: 本系列项目源码下载地址:https://github.com/GarsonZhang/G ...

  7. GZFramwork数据库层《三》普通主从表增删改查

    运行结果: 使用代码生成器(GZCodeGenerate)生成tb_Cusomer和tb_CusomerDetail的Model 生成器源代码下载地址: https://github.com/Gars ...

  8. GZFramwork数据库层《二》单据表增删改查(自动生成单据号码)

    运行效果: 使用代码生成器(GZCodeGenerate)生成tb_EmpLeave的Model 生成器源代码下载地址: https://github.com/GarsonZhang/GZCodeGe ...

  9. GZFramwork数据库层《一》普通表增删改查

    运行结果:     使用代码生成器(GZCodeGenerate)生成tb_MyUser的Model 生成器源代码下载地址: https://github.com/GarsonZhang/GZCode ...

随机推荐

  1. authz_core_module

    w https://httpd.apache.org/docs/trunk/mod/mod_authz_core.html codeigniter index.html .htaccess <I ...

  2. python open-falcon docker.WEB developers---flask,---django.

    http://www.verydemo.com/demo_c281_i2477.html (python Gevent – 高性能的Python并发框架) http://www.django-rest ...

  3. 用linux c求最大公约数

    我写了两中函数,一个是辗转相除法一个是更相减损法,主要代码如下: /*辗转相除法*/int gcd(int a, int b) { ) { return b; } else { return gcd( ...

  4. disable的错误使用

    表单中的input设为disable后数据无法提交. 如果需要设置无法修改效果,但又想表单提交数据,可以设置readonly.

  5. ISO C++标准委员会不是一个一般意义上权力机构,基本上愿意交会费,愿意自己出时间,出酒店机票,出提案,就可以申请加入。

    ISO C++标准委员会不是一个一般意义上权力机构,基本上愿意交会费,愿意自己出时间,出酒店机票,出提案,每年全世界参加会议被专家巨细靡遗地评头论足,就可以申请加入. 所以参加标准委员会背景各异,有人 ...

  6. python学习笔记(十一)redis的介绍及安装

    一.redis简介 1.redis是一个开源的.使用C语言编写的.支持网络交互的.可基于内存也可持久化的Key-Value数据库.       2.redis的官网地址,非常好记,是redis.io. ...

  7. koa2简单demo

    // 导入koa,和koa 1.x不同,在koa2中,我们导入的是一个class,因此用大写的Koa表示: const Koa = require('koa'); const Router = req ...

  8. 2017 Multi-University Training Contest - Team 4 hdu6071 Lazy Running

    地址:http://acm.split.hdu.edu.cn/showproblem.php?pid=6071 题目: Lazy Running Time Limit: 2000/1000 MS (J ...

  9. 【转】阿里巴巴技术专家杨晓明:基于Hadoop技术进行地理空间分析

    转自:http://www.csdn.net/article/2015-01-23/2823687-geographic-space-base-Hadoop [编者按]交通领域正产生着海量的车辆位置点 ...

  10. Web服务器文件传输程序客户端程序实现

    1. 客户端程序--主函数 客户端主程序的流程图如下: 主程序主要是分析输入的命令,根据不同命令调用不同的函数处理或者进行出错处理,函数代码如下: #include "common.h&qu ...