DataRow[] rows = dt.Select("verified=yes); // Replace your ColumnName here, it will filter the records
if (rows != null && rows.Count() > 0)
{
Label2.Text = "already verified";
}
else
{
Label2.Text = "already not verified";
}
答案 0 :(得分:1)
您可以查询DataRow数组:
var exists = (from x in rows
where x != null
let col1 = x["columnName"]
where col1 != DBNull.Value && col1.ToString() == "somevalue"
select x).Any();
Label2.Text = exists ? "already verified" : "already not verified";
答案 1 :(得分:0)
protected void Button1_Click(object sender, EventArgs e)
{
string TabName = TextBox1.Text;
string cmd = "Data Source=SQL5026;Initial Catalog=DB ...";
int exists;
SqlCommand check = new SqlCommand("select case when exists((select * from information_schema.tables where table_name = '" + TabName + "')) then 1 else 0 end",new SqlConnection (cmd));
check.Connection.Open();
exists = (int)check.ExecuteScalar();
if (exists > 0)
{
Label1.Text = "OK";
}
else
{
Label1.Text = "NO";
}
}