注册 登录
编程论坛 VC.NET论坛

DataSet数据绑定问题

伍则帝 发布于 2013-12-24 19:34, 1441 次点击
string strConnection = "data source=(local);initial catalog=PIMS;user id=sa;password=111";
            SqlConnection sc = new SqlConnection(strConnection);
             adapterContactType = new SqlDataAdapter("select * from ContactsType where users_id='"+user.UsersId+"'", sc);
             SqlCommandBuilder builderConatacts = new SqlCommandBuilder(adapterContactType);
           DataSet  ds = new DataSet();
            adapterContactType.Fill(ds);

            DataTable tb = ds.Tables[0];
            string text=tvContactType.SelectedNode.Text;
            foreach (DataRow dr in tb.Rows)
            {
                if (dr["contactstype_name"].ToString() == text) {
                    tb.Rows.Remove(dr);
                    break;
                }
            } tvContactType.Nodes[0].Nodes.Clear();
            adapterContactType.Update(ds);
            ds.AcceptChanges();
为什么红色部分不起作用
1 回复
#2
Issac_abc2014-07-03 15:36
remove()函数用于删除指定的文件
注意RemoveAt
因为ListItemCollection中Remove方法要求的参数,必须是ListItem类型实例.
而RemoveAt方法接受int型参数.
1