Topicname = TBnameTopic.Text
TopicDetail = TBmassage.Text
Conn.Open()
Dim strbad As String = "select max(Id_BadWord) as maxbad_id from BadWord"
Dim dataAdpe As New SqlDataAdapter(strbad, Conn)
Dim dataset As New DataSet()
dataAdpe.Fill(dataset, "Id_BadWord")
maxbad_id = dataset.Tables("Id_BadWord").Rows(0)(maxbad_id) - 1
Conn.Close()
Conn.Open()
Dim strbad1 As String = "select BadWord from BadWord "
Dim dataAdpe1 As New SqlDataAdapter(strbad1, Conn)
Dim dataset1 As New DataSet()
dataAdpe1.Fill(dataset1, "BadWords")
For i = 0 To maxbad_id
If Topicname = dataset1.Tables("BadWords").Rows(i)("BadWord") Then
MsgBox("โปรดใช้คำที่สุภาพ")
TBnameTopic.Text = ""
TBnameTopic.Focus()
Exit Sub
ElseIf (Topicname.Trim = "") Then
MsgBox("กรุณาป้อนหัวข้อกระทู้")
TBnameTopic.Focus()
Exit Sub
End If
Next
For i = 0 To maxbad_id
If (TopicDetail = dataset1.Tables("BadWords").Rows(i)("BadWord")) Then
MsgBox("โปรดใช้คำที่สุภาพ")
TBmassage.Text = ""
TBmassage.Focus()
Exit Sub
ElseIf (TopicDetail.Trim = "") Then
MsgBox("กรุณาป้อนข้อความ")
TBmassage.Focus()
Exit Sub
End If
Next
Conn.Close()
Tag : .NET, Ms SQL Server 2008, Web (ASP.NET), VB.NET