我编写了以下代码来过滤想要通过邮寄或电子邮件发送时事通讯的人:
Sub loadoverviewnewsletter()
Dim sql As String
Dim sql1 As String
If newslettermail = True Then
sql = "SELECT * FROM Donateurs WHERE 'Newsletter per e-mail' =-1"
sql1 = "SELECT * FROM Donateurs WHERE 'Newsletter per e-mail' =-1"
ElseIf newsletterpost = True Then
sql = "SELECT * FROM Donateurs WHERE 'Newsletter per post' =-1"
sql1 = "SELECT * FROM Donateurs WHERE 'Newsletter per post' =-1"
ElseIf newsletternew = True Then
sql = "SELECT * FROM Donateurs WHERE 'Newsletter per post' =0 AND 'Nieuwsbrief per e-mail' =0"
sql1 = "SELECT * FROM Donateurs WHERE 'Newsletter per post' =0 AND 'Nieuwsbrief per e-mail' =0"
Else
sql = "SELECT * FROM Donateurs"
sql1 = "SELECT * FROM Donateurs"
End If
Dim adapter As New MySqlClient.MySqlDataAdapter(sql, modConnectorHandler.ServerString)
Dim dt As New DataTable("newsletteroverview")
adapter.Fill(dt)
ShowDonateurs.datagrid.DataSource = dt
ShowDonateurs.ShowDialog()
Dim adapter1 As New MySqlClient.MySqlDataAdapter(sql1, modConnectorHandler.ServerString)
Dim cmd1 As New MySqlClient.MySqlCommand(sql1, modConnectorHandler.mysqlconnection)
modConnectorHandler.mysqlconnection.Open()
Dim myreader As MySqlClient.MySqlDataReader = cmd1.ExecuteReader
myreader.Read()
modConnectorHandler.mysqlconnection.Close()
OverviewNewsLetter.Close()
不幸的是,它返回一个空的数据网格,而当我选择 newsletternew 选项时,它会显示完整的表格。“Newsletter per e-mail”和“Newsletter per post”字段是 tinyint 字段,其值可以是 -1(表示已在应用程序中选中)和 0(表示未选中)。
我真的不明白为什么它不起作用..我希望任何人都可以提供帮助。