My loop always stop when encounter a False return
What I expect is to run other code block if False is return
The loop stop whem False is return form this
If isReg(dr(1).ToString(), dr(2).ToString().Substring(6, 5)) = True Then
When False return, the code in Else block mus be run before going to Next item on my Reader.
But my codes seems correct..I can't find where that error came from.
But my suspect is this,
Code:If Not sendRequest(dr(1).ToString(), generateRequest(dr(2).ToString().Substring(6, 5), dr(2).ToString().Substring(11, 7), dr(2).ToString().Substring(19, 3))) Then 'if false, do something before going to Next End If
Code:Private Sub loopRequestedCode() Dim da As New MySqlDataAdapter() Dim ds As New DataSet() Dim dt As DataTable Dim dr As DataRow Dim conn As MySqlConnection = New MySqlConnection() Try conn.ConnectionString = clsComm.connString() Dim SQL As String = "SELECT * from tbl_request" conn.Open() da.SelectCommand = New MySqlCommand(SQL, conn) Dim myCB As New MySqlCommandBuilder(da) da.Fill(ds, "Request") dt = ds.Tables(0) For Each dr In dt.Rows If isMatch(dr(2).ToString()) = True Then If isReg(dr(1).ToString(), dr(2).ToString().Substring(6, 5)) = True Then If Not sendRequest(dr(1).ToString(), generateRequest(dr(2).ToString().Substring(6, 5), dr(2).ToString().Substring(11, 7), dr(2).ToString().Substring(19, 3))) Then 'if false, do something before going to Next End If Else If Not sendRequest(dr(1).ToString(), notReg) Then 'if false, do something before going to Next End If End If Else If Not sendRequest(dr(1).ToString(), invalidReq) Then 'if false, do something before going to Next End If End If Next ds.Dispose() conn.Close() Catch ex As Exception 'TODO: catch error here Finally conn.Close() End Try End SubCode:Private Function isReg(ByVal sender As String, ByVal sID As String) As Boolean Dim MyDA As New MySqlDataAdapter() Dim MyDS As New DataSet() Dim conn As MySqlConnection conn = New MySqlConnection() conn.ConnectionString = clsComm.connString() Dim SQL As String = "SELECT * from tbl_tableS WHERE stID='" + sID + "'" conn.Open() MyDA.SelectCommand = New MySqlCommand(SQL, conn) Dim cb As New MySqlCommandBuilder(MyDA) MyDA.Fill(MyDS, "isReg") If MyDS.Tables Is Nothing Then Return False Else Dim dt As DataRow = MyDS.Tables(0).Rows(0) Dim fromSender As String = sender.Remove(0, 3) Dim fromDB As String = dt(7).ToString().Remove(0, 1) If (fromSender.Equals(fromDB)) = True Then Return True Else Return False End If End If conn.Close() End Function




Reply With Quote