如果条件不匹配,如何回到上一步的功能.. [英] how to get back to upper step of function if condition not matched..

查看:81
本文介绍了如果条件不匹配,如何回到上一步的功能..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于Eg我有这个选择函数。

For Eg i have this Select Function.

 Try
            Query = "Select * From [ClientMaster] where [clientid] = '100001' "
            '  How to return here  with new query
            SqlCmd = New SqlCommand(Query, ConnC())

            '//Execute the query
            ' Dim comdr As SqlDataReader = 
            SDR = SqlCmd.ExecuteReader()
            If SDR.HasRows = True Then
                While SDR.Read
                    ' idn = comdr.GetInt32(0)
                    t1.Text = SDR.GetInt32(0).ToString
                    d2.Value = SDR.GetDateTime(1)

                End While

            Else
                Query = "Select * From [ClientMaster] where [clientid] = '100002'"
            End If


        Catch ex As Exception
        End Try




现在以防万一当第一个查询数据不是fount时我想更改查询并返回执行带有新查询的命令..


now in case when with first query data is not fount i want to change query and return to execute command with new Query..

Pradeep Yadav (社交MSDN)

Pradeep Yadav (Social MSDN)

推荐答案

 

Around your code

SDR.HasRow = false
Do SDR.Hasrow = true
..........................
循环

SDR.HasRow = false Do Until SDR.Hasrow = true .......................... Loop

并删除 

Catch ex As Exception
End Try

在第一次专业检查时,您的代码将被标记为使用危险。 

At the first professional inspection your code will be branded as dangerous to use. 





这篇关于如果条件不匹配,如何回到上一步的功能..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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