我想检查数据集列中存在的给定值。 我是使用分隔符插入值并存储在列名fld empname中。 示例数据集字段fldempname具有值Hari,vinoth,Arun。假设我再次插入值hari和arun意味着它显示错误消息像这个Employee name已经存在,否则插入的值。 请帮助我..我想检查数据集列中是否存在给定值
我的部分代码是在这里..
for (int i = 0; i < lstbox.Items.Count; i++)
{
if (lstbox.Items[i].Selected)
{
string id = lstbox.Items[i].Text;
DataSet4TableAdapters.sp_getallattendancesetupTableAdapter TA1 = new DataSet4TableAdapters.sp_getallattendancesetupTableAdapter();
DataSet4.sp_getallattendancesetupDataTable DS1 = TA1.GetData();
if (DS1.Rows.Count == 0)
{
employee = employee + lstbox.Items[i].Text + ",";
}
else if (DS1.Rows.Count > 0)
{
foreach (DataRow dr in DS1.Rows)
{
foreach (string category in dr["fldemployee"].ToString().Split(','))
{
if (category != "")
{
if (category == id)
{
Value = Value + lstbox.Items[i].Text + "\\n";
break;
}
}
continue;
}
}
}
}
感谢您的朋友我得到了结果..... – 2012-02-02 09:06:57