///
<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 ;
}