Asp.net BC30201:应为表达式
当aspx代码在我的本地计算机上的IIS下运行时,以下代码行给出了上述错误Asp.net BC30201:应为表达式,asp.net,vb.net,Asp.net,Vb.net,当aspx代码在我的本地计算机上的IIS下运行时,以下代码行给出了上述错误 Details = If(.GetString(2) = "", "", "<div><b>" & .GetString(2) & "</b></div>") Details=If(.GetString(2)=“”、“”、“”和.GetString(2)和“”) 在生产web服务器上运行完全相同的代码时不会出错。 我刚刚接管了这个网站,我以前从未遇到过这
Details = If(.GetString(2) = "", "", "<div><b>" & .GetString(2) & "</b></div>")
Details=If(.GetString(2)=“”、“”、“”和.GetString(2)和“”)
在生产web服务器上运行完全相同的代码时不会出错。
我刚刚接管了这个网站,我以前从未遇到过这种类型的If语句
下面是出现BC30201错误的上述语句前面的代码
' Execute SQL procedure to fetch performance details
With New SQLCommand("FetchPerformance1", New SQLConnection(ConfigurationManager.ConnectionStrings("C1").ConnectionString))
.Parameters.AddWithValue("@Performance", Code)
.Parameters.AddWithValue("@Filters", Convert.ToByte(Mid(Query, 24, 1), 16))
.CommandType = StoredProcedure : .Connection.Open
With .ExecuteReader(CloseConnection)
' If performance not found ...
If Not .Read
' Display message page:
' Terminate script:
.Close : Response.End
End If
' Construct performance details string:
If .GetInt32(0) > 0 Then Links = "<a href=""view3.aspx" & Left(Query, 24) & Hex(.GetInt32(0)) & """ style=""float: left""><<</a>"
If .GetInt32(1) > 0 Then Links &= "<a href=""view3.aspx" & Left(Query, 24) & Hex(.GetInt32(1)) & """ style=""float: right"">>></a>"
执行SQL过程以获取性能详细信息
使用新的SQLCommand(“FetchPerformance1”、新的SQLConnection(ConfigurationManager.ConnectionString(“C1”).ConnectionString))
.Parameters.AddWithValue(“@Performance”,代码)
.Parameters.AddWithValue(“@Filters”,Convert.ToByte(Mid(查询,24,1),16))
.CommandType=StoredProcess:.Connection.Open
带.ExecuteReader(闭合连接)
'如果找不到性能。。。
如果没有,请阅读
'显示消息页:
'终止脚本:
.Close:响应。结束
如果结束
'构造性能详细信息字符串:
如果.GetInt32(0)>0,则Links=“”
如果.GetInt32(1)>0,则链接&=“”
将IIS配置为使用ASP.NET版本:4.0.30319.36373。它工作正常您遇到了哪种错误?语法看起来很奇怪。点运算符(
)表示您正在访问对象的方法,但点之前没有任何内容。另外,if表示应该在true
和false
之间做出决定,这里没有这样的事情bc30201:Expression expected是我得到的错误。点运算符(.)指记录的第三个字段。我的第二个问题是,我没有完全理解if声明试图实现的目标。我认为我们需要的不仅仅是一行。给我们一些关于它的代码。还有,我们要看哪种语言?语言是VB,我今晚回来时会添加更多代码。失败语句之前的代码是根据请求添加的,原因是.Net 2.0版中的VB不支持If
运算符