需要引用: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. glibc-2.23_malloc_consolidate_浅析

  2. 完全用nosql轻松打造千万级数据量的微博系统

    其实微博是一个结构相对简单,但数据量却是很庞大的一种产品.标题所说的是千万级数据量也并不是一千万条微博信息而已,而是千万级订阅关系之间发布.在看 我这篇文章之前,大多数人都看过sina的杨卫华大牛的微 ...

  3. Service Receiver Activity 之间的通信

    一.Activity与Service 1. 通过Intent,例子如下: Intent intent = new Intent(this, Myservice.class); // intent .p ...

  4. linux 系统性能指标

    一.查看CPU使用情况 cpu使用率反映的是当前cpu的繁忙程度,忽高忽低的原因在于占用cpu处理时间的进程可能处于io等待状态但却还未释放进入wait. 平均负载(loadaverage)是指某段时 ...

  5. 0701-spring cloud config-简介、Config Server开发、Config Client开发

    一.概述 参看地址: https://cloud.spring.io/spring-cloud-static/Edgware.SR3/single/spring-cloud.html#_spring_ ...

  6. 005-Shell echo命令

    一.概述 Shell 的 echo 指令,用于字符串的输出.命令格式: echo string 可以使用echo实现更复杂的输出格式控制. 1.显示普通字符串: echo "It is a ...

  7. 003-linux基本目录介绍

    一.文件系统的类型 LINUX有四种基本文件系统类型:普通文件.目录文件.连接文件和特殊文件,可用file命令来识别. 普通文件:如文本文件.C语言元代码.SHELL脚本.二进制的可执行文件等,可用c ...

  8. django高级之爬虫基础

    目录: 爬虫原理 requests模块 beautifulsoup模块 爬虫自动登陆示例 一.爬虫原理 Python非常适合用来开发网页爬虫,理由如下:1.抓取网页本身的接口相比与其他静态编程语言,如 ...

  9. FB05付款清帐Function

    函数组:FIPI-->内部FI过帐接口1.CALL FUNCTION 'POSTING_INTERFACE_START'. -->Initial information for inter ...

  10. Spring基本功能-IOC

    一.SpringIOC Spring的控制反转:把对象的创建,初始化,销毁的过程交给SpringIOC容器来做,由Spring容器控制对象的生命周期. 1.1 启动Spring容器的方式: (1)加载 ...