浅谈如何建立三层体系结构的ASP应用程序
2006-04-08 11:59:20 来源:WEB开发网这里根据EMPLID创建Employee对象,注意数据库中的值是赋给三个私有变量,而不是直接赋值给属性,如果你单步调试就会发现,给msEMPLID赋值会调用Property Let EMPLID,也就是给属性赋值。
下面我们再创建一个类Employees,并填加如下方法:
private colQualifiedList as new Collection
private mnCurrentIndex as integer
Public Sub GetQualifiedList()
dim conn as new Connection
dim rs as new Recordset
dim sql as string
'Suppose that you create a DSN in the control panel, the connectionstring property
'can also be dsn-less string
conn.ConnectionString="dsn=dsnname;uid=username;password=pwd"
conn.open
sql="select EMPLID from Employee where Score>=60 order by Score desc"
with rs
.open sql,conn,1,3
if .eof and .bof then
exit sub
else
do while not .eof
dim oEmployee as new Employee
oEmployee.Create trim(.Fields("EMPLID"))
colQualifiedList.Add oEmployee
set oEmployee=nothing
loop
end if
.close
end with
set rs=nothing
conn.close
set conn=nothing
End Sub
更多精彩
赞助商链接