【发布时间】:2014-02-14 08:33:17
【问题描述】:
我有一个数据库表,我正在查询该表以检查值是否已经存在(对于登录应用程序)。
我有一个数据适配器,但我不知道如何检查数据适配器是否包含我要查找的值...
这里是c#:
string connectionString = @"Data Source=.\SQLEXPRESS;Database=Employee;Integrated Security=true";
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter da = new SqlDataAdapter("SELECT UName FROM EVUSERS WHERE UName = '" + userName + "'", connection);
da.Fill(dt);
//this message displays proving the adapter contains values
if(da != null)
{
MessageBox.Show("name exists");
}
}
我只是想知道我该怎么说
if (da contains username) { do something }
谢谢。
【问题讨论】:
标签: c# sql dataadapter