C# 判断某列是否为主键
来源:互联网 发布:宁夏干部网络培训教育 编辑:程序博客网 时间:2024/06/11 12:42
/// <summary>
/// 判断某列是否为主键
/// </summary>
/// <param name="columnName">列的物理名称</param>
/// <param name="tableName">表名</param>
/// <returns></returns>
public bool IsPrimaryKey(String columnName,String tableName)
{
SqlParameter[] parameters = new SqlParameter[3];
parameters[0] = new SqlParameter("@table_name", tableName);
parameters[1] = new SqlParameter("@table_owner", null);
parameters[2] = new SqlParameter("@table_qualifier", null);
DataRowCollection drc = SqlHelper.ExecuteDataset(Common.GetConnString, CommandType.StoredProcedure, "sp_pkeys", parameters).Tables[0].Rows;
if (drc.Count==0 || (drc[0]["COLUMN_NAME"].ToString() != columnName))
return false;
else
return true;
}
/// 判断某列是否为主键
/// </summary>
/// <param name="columnName">列的物理名称</param>
/// <param name="tableName">表名</param>
/// <returns></returns>
public bool IsPrimaryKey(String columnName,String tableName)
{
SqlParameter[] parameters = new SqlParameter[3];
parameters[0] = new SqlParameter("@table_name", tableName);
parameters[1] = new SqlParameter("@table_owner", null);
parameters[2] = new SqlParameter("@table_qualifier", null);
DataRowCollection drc = SqlHelper.ExecuteDataset(Common.GetConnString, CommandType.StoredProcedure, "sp_pkeys", parameters).Tables[0].Rows;
if (drc.Count==0 || (drc[0]["COLUMN_NAME"].ToString() != columnName))
return false;
else
return true;
}
- C# 判断某列是否为主键
- 判断某列是否是主键列(sql server)
- C#中判断数据库列值是否为空
- oracle中判断某列是否为数字
- oracle中判断某列是否为数字
- c#判断是否为数字
- C# 判断是否为数字
- C#判断是否为图片
- C#判断是否为图片 .
- C#判断是否为数字
- C# 判断是否为数字
- C# 判断是否为数字
- C# 判断是否为数字
- C# 判断是否为回文
- C# 判断是否为json
- Oracle判断表、列、主键是否存在的方法
- 获取数据库所有列以及列的类型是否为空是否为默认值是否为主键
- 查看sql某字段是否为主键
- SQLserver数据文件(MDF)的页面文件头结构剖析
- VS2008中VC示例源代码不能执行的问题
- 编程语言的学习和选择会影响我们的未来。
- 转:关于win2003+iis6服务器设置排错集锦及其他
- C++ Template Metaprogramming 第九章试译: Crossing the Compile-Time/Runtime Boundary (1)
- C# 判断某列是否为主键
- 知道自己获得MVP今天很高兴
- 怎样让.Net2.0的Membership使用已存在的Sql Server2000/2005数据库
- socket异步处理问题
- VS.NET2005安装部署之实战
- .Net Remoting中Remote Server的Port占用/释放问题
- ASP.NET AJAX 之服务器端页面流程
- 信道、接收器、接收链和信道接受提供程序
- .Net服务组件(ServicedComponent)简介及其使用