让VBScript 一边去吧。ASP现在全部用成熟的VB语言来书写。感觉还不错,不是吗?不过,VB有了一些改动。VB中的主要改变,不再有Set
& Let,不再有缺省属性,Parenthesis现在被称为SUBS,Arguments需通过缺省设置来实现 BYVAL,Integer 为32位,Long为64位,And"
and "Or“ 省略了,通过上面的清单不难发现,VB的许多变动是有实际意义的,也是有明显进步的。
不过,通过上面这些变动却不能改变一个事实,你许多现有的代码将不会正常运作。
我们先看个完整的查询的例子,这个例子也显示了当查询显示没有纪录返回和如何检测返回NULL数据的情况
$#@60;%@ OutputCache duration="240"%$#@62;
$#@60;%--
the above OutputCache directive is pretty slick
It means that for 240 seconds (4 minutes) the page will only read the database
once
only the first user hitting it forces a database read
--%$#@62;
$#@60;%@ Import Namespace="System.Data" %$#@62;
$#@60;%@ Import Namespace="System.Data.ADO" %$#@62;
$#@60;script language="VB" runat="server"$#@62;
Sub Page_Load(Src As Object, E As EventArgs)
Dim DS As DataSet
Dim MyConnection As ADOConnection
Dim MyCommand As ADODataSetCommand
dim strconn as string
dim strSQL as string
strSQL="select * from Publishers where state="NY""
MyConnection = New ADOConnection(strconn)
MyCommand = New ADODataSetCommand(strSQL,MyConnection)
DS = new DataSet()
MyCommand.FillDataSet(ds, "Publishers")
MyDataGrid.DataSource=ds.Tables("Publishers").DefaultView
MyDataGrid.DataBind()
End Sub
$#@60;/script$#@62;
$#@60;html$#@62;$#@60;head$#@62;
$#@60;title$#@62;Grid of New York Data$#@60;/title$#@62; >
$#@60;/head$#@62;
$#@60;body bgcolor="#FFFFFF"$#@62;
$#@60;h3$#@62;$#@60;font face="Verdana"$#@62;New York Data$#@60;/font$#@62;$#@60;/h3$#@62;