I am writing a Class in ASP
I am trying to pass a database connection object into the class to use within the class
EX: The page:
-------------
set MyConn = Server.CreateObject("ADODB.Connection"
MyConn.Open {My Connection String}
set MyObj = New MyObject
MyObj.Connection = MyConn
response.write MyObj.DoSomething(string)
----------
the class:
----------
Class MyObject
private objConn
public property let Connection(ByRef vData)
objConn = vData
end property
function DoSomething(MyData)
sql = "select * from table where something = " & MyData
set rs=objConn.Execute(sql)
DoSomething=rs("Field"
end function
end class
----------
this results in a Object Expected error
objConn is not empty cause with a test it returns
"Provider=MSSQLSERVER;SERVER=etc...."
if i do this, how ever, the code will work:
public property let Connection(ByVal vData)
set objConn = Server.CreateObject("ADODB.Connection"
objConn.open = vData
end property
but it seems to me this would open 2 connections to the database, wasting resources.. whats the proper syntax to pass as object into the class?
public property let Connection(ByRef vData as Object)
produces a syntax error expected ')'
thanx
Fid
I am trying to pass a database connection object into the class to use within the class
EX: The page:
-------------
set MyConn = Server.CreateObject("ADODB.Connection"
MyConn.Open {My Connection String}
set MyObj = New MyObject
MyObj.Connection = MyConn
response.write MyObj.DoSomething(string)
----------
the class:
----------
Class MyObject
private objConn
public property let Connection(ByRef vData)
objConn = vData
end property
function DoSomething(MyData)
sql = "select * from table where something = " & MyData
set rs=objConn.Execute(sql)
DoSomething=rs("Field"
end function
end class
----------
this results in a Object Expected error
objConn is not empty cause with a test it returns
"Provider=MSSQLSERVER;SERVER=etc...."
if i do this, how ever, the code will work:
public property let Connection(ByVal vData)
set objConn = Server.CreateObject("ADODB.Connection"
objConn.open = vData
end property
but it seems to me this would open 2 connections to the database, wasting resources.. whats the proper syntax to pass as object into the class?
public property let Connection(ByRef vData as Object)
produces a syntax error expected ')'
thanx
Fid