string sql = "select * from table where col1='a' or col2='a' or col3='a'";
DataTable dt = DB.GetTable(sql);
int cnt = dt.Columns.Count;
for(int i=0; i<cnt; i++)
{
if(dt.Rows[0][i].ToString()!="")
Response.Write("Column "+ dt.Columns[i].ColumnName +" exists yet;<br />");
}

解决方案 »

  1.   

    晕楼上的怎么连datatable也出来了,
    我的意思是一张表有多个唯一自段,我想在插入数据后给客户提示具体哪个字段数据表中已经有了,
    平时可以写select * from where id="id"
    select * from where name="name"
    select * from where nameid="nameid"
    难道必须写三个语句一个一个的来判断吗?没有好的办法吗
      

  2.   

    select count(id) as Existed from [table] where id="id" or name="name" or  nameid="nameid"