I've written a very small DLL to handle calls to a database. It's going to be much bigger and more useful than it is now in future, this is something of a pilot, just to check that I can get it working. Well, at the moment it seems I can't. The only code in the DLL is below:
Public Function getRS(ByVal strSQL As String, ByVal dbName As String)
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = CreateObject("adodb.connection"
conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & dbName
conn.Open
Set rs = CreateObject("ADODB.Recordset"
rs.ActiveConnection = conn
rs.CursorLocation = adUseClient
rs.Source = strSQL
rs.Open strSQL, , adOpenForwardOnly, adLockReadOnly
Set getRS = rs
rs.ActiveConnection = Nothing
conn.Close
Set conn = Nothing
Exit Function
ErrorHandler:
Err.Raise conn.Errors.Item(0).Number, _
conn.Errors.Item(0).Source, _
conn.Errors.Item(0).Description
Set rs = Nothing
Set conn = Nothing
End Function
I use ASP to access this class and attempt to use it to open a recordset:
<%
Dim obj
Dim RS
dim path
path=server.mappath("database/***.mdb"
set obj = Server.CreateObject("DataAccess.clsAccess"
set RS=obj.getRS("select * from parts where ", cstr(path))
set obj=nothing
while not rs.eof
%>
<%=RS("PARTNO"
%><br>
<%
wend
%>
Can anyone spot the problem? Is it with the server.mappath? The error I get is a type mismatch on the line that calls getRS, which makes me think that maybe I've done something stupid.
Thanks for any help.
Public Function getRS(ByVal strSQL As String, ByVal dbName As String)
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Set conn = CreateObject("adodb.connection"
conn.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & dbName
conn.Open
Set rs = CreateObject("ADODB.Recordset"
rs.ActiveConnection = conn
rs.CursorLocation = adUseClient
rs.Source = strSQL
rs.Open strSQL, , adOpenForwardOnly, adLockReadOnly
Set getRS = rs
rs.ActiveConnection = Nothing
conn.Close
Set conn = Nothing
Exit Function
ErrorHandler:
Err.Raise conn.Errors.Item(0).Number, _
conn.Errors.Item(0).Source, _
conn.Errors.Item(0).Description
Set rs = Nothing
Set conn = Nothing
End Function
I use ASP to access this class and attempt to use it to open a recordset:
<%
Dim obj
Dim RS
dim path
path=server.mappath("database/***.mdb"
set obj = Server.CreateObject("DataAccess.clsAccess"
set RS=obj.getRS("select * from parts where ", cstr(path))
set obj=nothing
while not rs.eof
%>
<%=RS("PARTNO"
<%
wend
%>
Can anyone spot the problem? Is it with the server.mappath? The error I get is a type mismatch on the line that calls getRS, which makes me think that maybe I've done something stupid.
Thanks for any help.