if语句中的错误 [英] Error in if statement
本文介绍了if语句中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
For Each dr1 In reportData.Tables(0).Rows
Dim con4 As New SqlConnection("Data Source=INSIGHT-002;Initial Catalog=TNVKP_8;user id=sa;")
con4.Open()
Dim cmdclustr As New SqlCommand("select ParentUnitID from M_RptUnit where Rpt_Unit_ID='" + dr1("VPRC_ID") + "'", con4)
Dim redclustr As SqlDataReader
redclustr = cmdclustr.ExecuteReader()
If (redclustr.Read()) Then
clusterid = redclustr("ParentUnitID")
Dim login As String
login = Convert.ToString(Session(ssnLOGIN_ID)).ToUpper()
'If ((Convert.ToString(redclustr("ParentUnitID"))).ToUpper() = (Convert.ToString(Session(ssnLOGIN_ID))).ToUpper()) Then
Response.Write(login)
Response.Write(clusterid)
'Response.End()
If clusterid.ToString() = login.ToString() Then
check = 1
Response.Write("HAI HAI")
Response.Write(check)
Response.End()
Else
check1 = 2
Response.Write(check1)
Response.End()
End If
End If
redclustr.Close()
Next
从上面的代码我有错误
为此,它总是执行else部分(CHECK1 = 2)后解决方案
在此先感谢
From the above code i m having an error
Always it executing the else part(CHECK1=2) post solution for this
Thanks in advance
推荐答案
只需在调试器中运行它并跟踪对clusterid
和login
的所有分配. 琐碎的是的,但是您不会显示所有相关代码,这是解决此类简单问题的常规且简单的方法.总是在问一个问题之前 .
—SA
Just run it under debugger and track all assignments to bothclusterid
andlogin
.
Trivial, yes, but you don''t show all relevant code, and this is the regular and simple way to solve such simple problems. Always do it before you ask a question.
—SA
这篇关于if语句中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文