Hi,
I am new to Classic ASP and VBScript, I come from a 6 month experience with ASP.NET.
The project I am working is a total mess and I am trying to add the most elementary software development concepts, such as reusability.
So the application consists of tens of ASP pages all opening and using the same database object, through the same connection string and settings.
So I have actually 2 questions:
1) can I create a VBScript "library" in the same way as we do with, say, JavaScript, adding a script src reference to a given .JS file?
There I will start putting code that is reused (and has been written over and over again...) throughout all the ASP pages. If so, how do I do that? So far I have seen this is done using the directive "#include file=..." within HTML comments - this is the way?
2) the step above I tried and it works, I just wanted to be sure that this is not an awkward workaround and that I am using the proper way of doing it. But real question - which I could not solve yet - is: I want to create a function that receives a SQL string and returns a database recordset object. How do I do that?
I have been trying something like
Function GetRecordSet(sql) Dim connection = Server.CreateObject("ADODB.Connection") connection.Open Application("MyApp") Dim recordSet = Server.CreateObject("ADODB.Recordset") recordSet.Open sql,connection ,3,3 on error resume next GetRecordSet = recordSet End Function
but it does not work. I call this function in an ASP file after adding the <!-- #include file="..." -->.
What am I missing? ASP will not return an object reference from a function?
Thanks