从CheckBoxList中删除选择 [英] Delete Selection from CheckBoxList

查看:55
本文介绍了从CheckBoxList中删除选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows应用程序,可以在一个复选框列表中显示来自访问数据库的用户

。我试图做的是从复选框列表中选择一个或多个用户

,循环并删除相应的

信息。我已经设置了一个文本框来打印生成的

的SQL字符串,它似乎是正确的。


UPDATE tblName SET EmployeeName = Null WHERE(ID IN (n1,n2));


如果我选择3个ID为44,67,78的用户并点击删除按钮,

只有id为44的用户才被删除,即使所有3个用户都在SQL字符串中反映了



有什么建议吗?

I have a windows application that displays users from access database
in a checkboxlist. What I am attempting to do is select a user or users
from the checkboxlist, loop through, and delete their corresponding
information. I have setup a textbox to print the SQL string that is
generated and it seems to be correct.

UPDATE tblName SET EmployeeName = Null WHERE (ID IN(n1,n2));

If I select 3 users with id''s 44, 67, 78 and click ''remove'' button,
only the user with id 44 is removed even though all 3 users are
reflected in the SQL string.

Any suggestions?

推荐答案

如果你真的想要删除你应该做的信息:


从tblName删除WHERE ID IN( n1,n2,n3)


但是如果你显示一些代码就更容易看出是否有问题


Greetz Peter


-

今天的编程是软件工程师之间的竞赛,他们正在努力建立更大,更好的防止白痴的程序,以及宇宙试图产生更大更好的白痴。到目前为止,宇宙正在赢得胜利。


" Will Lastname" < Wh是**** @ brinkster.net> schreef在bericht

新闻:11 ********************** @ g49g2000cwa.googlegr oups.com ...
If you realy want to delete the info you should do:

delete from tblName WHERE ID IN(n1,n2,n3)

but if you show some code it''s easier to see if something is wrong

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.

"Will Lastname" <wh****@brinkster.net> schreef in bericht
news:11**********************@g49g2000cwa.googlegr oups.com...
我有一个Windows应用程序,它在一个复选框列表中显示来自访问数据库的用户
。我试图做的是从复选框列表中选择一个或多个用户,循环并删除相应的
信息。我已经设置了一个文本框来打印生成的SQL字符串,它似乎是正确的。

UPDATE tblName SET EmployeeName = Null WHERE(ID IN(n1,n2));

如果我选择ID为'44,47,78的3个用户并点击''删除''按钮,
只有id为44的用户被删除,即使所有3个用户都是
反映在SQL字符串中。

有什么建议吗?
I have a windows application that displays users from access database
in a checkboxlist. What I am attempting to do is select a user or users
from the checkboxlist, loop through, and delete their corresponding
information. I have setup a textbox to print the SQL string that is
generated and it seems to be correct.

UPDATE tblName SET EmployeeName = Null WHERE (ID IN(n1,n2));

If I select 3 users with id''s 44, 67, 78 and click ''remove'' button,
only the user with id 44 is removed even though all 3 users are
reflected in the SQL string.

Any suggestions?



还有一件事,你在使用参数吗? br />

Greetz Peter


-

今天的编程是软件工程师努力建立的竞赛

更大,更好的防止白痴的程序,宇宙试图制作更大更好的白痴。到目前为止,宇宙正在赢得胜利。
One more thing, are you working with parameters?

Greetz Peter

--
Programming today is a race between software engineers striving to build
bigger and better idiot-proof programs, and the Universe trying to produce
bigger and better idiots. So far, the Universe is winning.


感谢Peter的快速回复。这是一个代码示例:


Dim strSQL As String =" UPDATE tblSoftware Set EmployeeName = Null

WHERE(ID IN("


Dim objConn As New OleDb.OleDbConnection

objConn.ConnectionString =

System.Configuration.ConfigurationSettings.AppSettings(" strConnection")


for c = 0 to i


iid = clBox.SelectedValue

Dim strSQLBuilder As String ="" ;


如果我> c那么


strSQLBuilder + = strSQLBuilder& iid&","


ElseIf i = c然后


strSQLBuilder + = iid&"));"


End如果


strSQL = strSQL& strSQLBuilder


下一页

我喜欢那个签名!

Thanks for the quick reply Peter. Here is a code sample:

Dim strSQL As String = "UPDATE tblSoftware Set EmployeeName = Null
WHERE (ID IN("

Dim objConn As New OleDb.OleDbConnection
objConn.ConnectionString =
System.Configuration.ConfigurationSettings.AppSett ings("strConnection")

For c = 0 To i

iid = clBox.SelectedValue
Dim strSQLBuilder As String = ""

If i > c Then

strSQLBuilder += strSQLBuilder & iid & ","

ElseIf i = c Then

strSQLBuilder += iid & "));"

End If

strSQL = strSQL & strSQLBuilder

Next
I love that signature by the way!


这篇关于从CheckBoxList中删除选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆