'***************************************** ' 类型: 属性 ' 目的: 根据获取的信息,创建数据库连接 ' 输入: a_strConn:数据类型字符串 ' 返回: 无 '***************************************** Public Property Let Conn(a_strConn) Dim strError SW_blnConn = false Set SW_objConn = CreateObject("Adodb.Connection") On Error Resume Next SW_objConn.Open a_strConn If Err.Number <> 0 Then strError = strError & "<br>创建Connection对象失败" On Error Goto 0
If Trim(strError)="" Then SW_blnConn = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">Conn属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设定或显示SQL语句。 ' 输入: a_strSQL: SQL语句。 ' 返回: SQL语句。 '***************************************** Public Property Let SQL(a_strSQL) Dim strError
SW_blnOpenRS = false SW_strSQL = a_strSQL
'创建RecordSet对象 Set SW_objRS = CreateObject("adodb.RecordSet") On Error Resume Next SW_objRS.Open SW_strSQL,SW_objConn,1,1 If Err.Number <> 0 Then strError = "<br>记录集打开失败" On Error Goto 0
If Trim(strError)="" Then SW_blnOpenRS = true Else SW_strError = SW_strError & " <tr bgcolor=""#336699"" height=""28""><td><font color=""#FFFFFF"">SQL属性:</font></td></tr>" & vbcrlf SW_strError = SW_strError & " <tr bgcolor=""#ffffff""><td>" & strError & "</td></tr>" & vbcrlf End If End Property
'***************************************** ' 类型: 属性 ' 目的: 设置需要显示的数据的字段名 ' 输入: a_strFldName:字段名字符串,多个字段之间以逗号分隔 ' 返回: 无 '***************************************** Public Property Let FieldList(a_strFldName) Dim strError
SW_blnFieldList = false If Trim(a_strFldName) <> "" Then SW_aryFldName = Split(LCase(a_strFldName),",") Else strError = strError & "<br>你必须设置需要显示的字段名,否则无法显示数据" End If