变量定义在IF...ENDIF里面,在IF后面的使用此变量的语句提示"变量未定义".
If Pwa.Length = 4 And IsNumeric(Pwa) Then
Dim SqlRead As SqlDataReader
Dim Sqlstr As String
Dim Sqlcmd As New SqlCommand
Dim Sqlconstr As String = "Data Source=CNC-ZC\sql2k;Initial talog=ydgs;Integrated Security=True"
Dim Sqlcnn As New SqlConnection(Sqlconstr)
Sqlstr = "select id,uname,psb,ISNULL(nhm,0)-ISNULL(donehm,0),ISNULL(nop,0)-ISNULL(doneop,0) from u where psa='" & Pwa & "'"
Sqlcnn.Open()
Sqlcmd.Connection = Sqlcnn
Sqlcmd.CommandText = Sqlstr
SqlRead = Sqlcmd.ExecuteReader
If SqlRead.HasRows = True Then
SqlRead.Read()
Pwb = SqlRead(2)
'Response.Write("通过")
Else
Response.Write("Start#N验证未通过!!End")
Exit Sub
End If
Else
Response.Write("Start#N验证未通过!!此用户不存在!!End")
Exit Sub
End If
Userid = SqlRead(0)
UserName = Trim(SqlRead(1))
Lishm = SqlRead(3)
Lisop = SqlRead(4)
SqlRead.Close()
以上一段代码提示SQLREAD未定义,如果把Dim SqlRead As SqlDataReader这一句放在IF外面就可以成功,其实通过IF语句能看出来在IF里如果不经过Dim SqlRead As SqlDataReader这段代码程序是跑不到下面的.谁能告诉我为什么报错.难道注册SQLREAD不能跨IF等语句???
相关推荐
linux shell脚本对未定义变量的判断以及if的用法详解
今天小编就为大家分享一篇linux shell脚本对未定义变量的判断以及if的用法详解,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
js判断变量是否未定义的代码
例如: if(!myVar01)alert(“发生错误”); // 该代码直接发生异常,因为变量myVar01没有申明 if(“undefined” == typeof myVar01)alert(“发生错误”); // 这样写才不至于发生异常 而: var myVar01; if(undefined == myVar01)alert(“发生错误”); // 该代码会正确运行 if(“undefined” == typeof myVar01)alert(“发生错误”); // 该代码同样会正确运行 结论:我们采用下面的方式来保证万无一失 if(“undefined” == typ
Linux shell脚本编程if语句的使用方法(条件判断)
主要介绍了Linux shell脚本编程if语句的使用方法,大家参考使用吧
if语句 、switch语句 、for循环、break、continue、while、do-while
if语句 、switch语句 、for循环、break、continue、while、do-while总结 if语句 对比if语句switch语句 1、if语句作用的数据类型:boolean类型。而switch语句作用的类型:byte,short,int,char,String。 2、编码习惯:if适合分支较少的情况,switch适合分支较多的情况。 //1.if语句 if(条件表达式){ } //2.if...else语句:二选一 if(条件表达式){ 语句块1; }else{ 语句块2; } //3.多重if语句:多选一 if(条件1){//成立 语句块1; }el
c语言if语句实例_C语言if语句和switch语句实例_If..._
1、.了解C语言的逻辑运算2、.学会使用if语句和switch语句3、.熟练掌握选择结构程序设计方法


