<%
Class Connection
Private Conn
Private dataSource
Private Key
Public Property Let DBPath(dS)
dataSource = ds
End Property
Public Property Let DBKey(k)
key = k
End Property
Public Property Get Link()
Link = Conn
End Property
Public Function DBOpen()
If dataSource = "" then
Response.Write("
Error: DBOpen()
Data Source not find.
DBPath Property not declared.
")
Else
Set Conn = Server.CreateObject("ADODB.Connection")
If key = "" then
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString = Server.MapPath(dataSource)
Conn.Open
Else
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="& Server.MapPath(dataSource) &"; Persist Security Info=True; Jet OLEDB:Database Password="& Key
End If
End If
End Function
Public Function DBClose()
If IsObject(Conn) then
Conn.Close
Set Conn = Nothing
Else
Response.Write("
Error: DBClose()
Database connection don't exists.
")
End If
End Function
End Class
%><!--#include file="cls_connection.asp" //-->
<%
Dim objCnx
Set objCnx = new Connection 'Chamando a classe
objCnx.DBPath = "banco.mdb" 'Informar o caminho virtual, pois utiliza o Server.MapPath
'objCnx.DBKey = "12345" 'Caso o Banco de Dados usar senha
objCnx.DBOpen()
strSQL = "SELECT * FROM registro ORDER BY code"
Set RS = Server.CreateObject("ADODB.RecordSet")
RS.Open strSQL,objCnx.Link(),3,3
Do while Not RS.EOF
response.write RS("usuario") &" - "& RS("senha") &"
"
RS.MoveNext
Loop
objCnx.DBClose()
%>
![]() |
CodigoFonte.net » CodigoFonte.eti.br » Procurando o que comprar? » MeuMural.com.br » Todos os Direitos Reservados © 2002/2008 |
Procurando Notebooks, Câmeras Digitais, iPhones?