需要引用: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. Spring Cloud Zuul与网关中间件

    Spring Cloud Zuul与网关中间件_网易订阅 http://dy.163.com/v2/article/detail/DC7L8UV10511HSJK.html

  2. Storm-源码分析-Topology Submit-Worker

    1 mk-worker 和其他的daemon一样, 都是通过defserverfn macro来创建worker (defserverfn mk-worker [conf shared-mq-cont ...

  3. 重点:怎样正确的使用QThread类(很多详细例子的对比,注意:QThread 中所有实现的函数是被创建它的线程来调用的,不是在线程中)good

    背景描述: 以前,继承 QThread 重新实现 run() 函数是使用 QThread唯一推荐的使用方法.这是相当直观和易于使用的.但是在工作线程中使用槽机制和Qt事件循环时,一些用户使用错了.Qt ...

  4. MapReduce学习笔记

    一.MapReduce概述 MapReduce 是 Hadoop 的核心组成, 是专用于进行数据计算的,是一种分布式计算模型.由Google提出,主要用于搜索领域,解决海量数据的计算问题. MapRe ...

  5. Mybatis框架学习总结-表的关联查询

    一对一关联 创建表和数据:创建一张教师表和班级表,这里假设一个老师只负责教一个班,那么老师和班级之间的关系就是一种一对一的关系. CREATE TABLE teacher( t_id INT PRIM ...

  6. FindBugs——帮助查找隐藏的bug

    FindBugs 1.什么是FindBugs FindBugs 是一个静态分析工具,它检查类或者 JAR 文件,将字节码与一组缺陷模式进行对比以发现可能的问题.有了静态分析工具,就可以在不实际运行程序 ...

  7. Linux登录欢迎图案

    命令提示符设置: export PS1='\n\[\e[37;1m[\]\[\e[31;1m\]\u\[\e[39;1m\]@\[\e[33;1m\]\H \[\e[34;1m\]\w\[\e[37; ...

  8. Uboot mmc命令解析&NAND flash uboot命令详解

    转载:http://blog.csdn.net/simonjay2007/article/details/43198353 一:mmc的命令如下: 1:对mmc读操作 mmc read addr bl ...

  9. linux下python编辑器的tab补全

    vi tab.py #!/usr/bin/env python # python startup file import sys import readline import rlcompleter ...

  10. matplotlib对LaTeX数学公式的支持

    Matlplotlib对LaTeX有一定的支持,如果记得使用raw字符串语法会很自然: xlabel(r"x2y4x2y4") 在matplotlib里面,可以使用LaTex的命令 ...