请问怎样判断记录标题没有重复? 开发环境为sql+asp.net 我建立了一个记录,里面有一个字段为Title,不能重复的。各位大虾,请问怎样判断记录的标题没有重复呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select val=count(title)注:这里最好使用主键或者索引 from *** 如果val=0,没重复,1也没重复,>=2,重复 if (GetRsCount("Table where title='"+Title.Text+"'")>0){ // 标题不能重复 return;}/// <summary> /// 获得表记录数 /// </summary> /// <param name="table_name">表名或者表名+条件,GetRsCount("t_user where id="+Request["id"])</param> /// <returns></returns> public int GetRsCount(string table_name) { string strSql; int intCount; Open(); strSql="select count(*) from "+table_name; SqlCommand cmd=new SqlCommand(strSql,cn); intCount=(int)cmd.ExecuteScalar(); cn.Close(); return intCount; }————————————————————————————————DotNet中华网,我们最原创:www.aspxcn.org 在sql语句中用in,后判断,如果没有返回,就证明没有相同的记录.不知这样是否可行? select val=count(title)注:这里最好使用主键或者索引 from *** where title = *** select count(Title) , Title,... form table group by Title .NET向access数据库插入长日期格式的问题急急... .net3.5的服务器支持.net2.0做的网站么 建立与服务器的连接时出错? 高分求ASP.Net2。0客户端打印代码实例! gridview能实现给每条记录显示为一个超链接指向对应的详细信息吗? 多个程序能不能有多个membership? server2003系统给网站配置ip不行 这句该怎么写? 该操作需要IIS集成管线模式 !!!!!!!!!!!!如何给一个gridview添加一个鼠标点击事件!!!!!!!!!!!急求 有谁用过ActiveReports for .NET么?帮忙那!!!! 把ppt文件保存为html
如果val=0,没重复,1也没重复,>=2,重复
{
// 标题不能重复
return;
}/// <summary>
/// 获得表记录数
/// </summary>
/// <param name="table_name">表名或者表名+条件,GetRsCount("t_user where id="+Request["id"])</param>
/// <returns></returns>
public int GetRsCount(string table_name)
{
string strSql;
int intCount;
Open();
strSql="select count(*) from "+table_name;
SqlCommand cmd=new SqlCommand(strSql,cn);
intCount=(int)cmd.ExecuteScalar();
cn.Close();
return intCount;
}————————————————————————————————
DotNet中华网,我们最原创:www.aspxcn.org
select val=count(title)注:这里最好使用主键或者索引 from *** where title = ***