一、在一个类中实例化另一个类(像下面那段代码),这样是否可以,有点像函数的嵌套那样,会不会影响效率问题?
二、下面这段代码为什么读不到任何内容,而如果只在一个类中用Command对象却可以读到内容?
Class LoadInfo
Public objRs, objConn
Public Id, Name, Password, Level, Email
Private Sub Class_Terminate()
Set objLoad = Nothing
Call CloseObj(objRs)
End Sub
'读取用户信息
Public Function LoadUserInfobyId(intId)
Set objLoad = New CommandDataInfo
objLoad.strSql = "SELECT * FROM [UserInfo] WHERE [User_ID] =" & CInt(intId)
Set objRs = objLoad.IUdata
Dim ReArr
ReArr = objRs.GetRows
Id = ReArr(0,0)
Name = ReArr(1,0)
Password = ReArr(2,0)
Level = ReArr(6,0)
Email = ReArr(3,0)
End Function
End Class
Class CommandDataInfo
Public objConn, objComm, strSql, strLink
Private Sub Class_Initialize()
Call OpenData(objConn)
Set objComm = Server.CreateObject("ADODB.Command")
objComm.ActiveConnection = objConn
objComm.CommandType = adCmdText
End Sub
Private Sub Class_Terminate()
Set objComm = Nothing
Call CloseObj(objConn)
End Sub
Public Function IUdata()
objComm.CommandText = strSql
objComm.Execute
If strLink <> "" Then
Response.Redirect strLink
End If
End Function
End Class