Click here to Skip to main content
16,008,942 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: create new folder in web site Pin
Dan_P3-May-05 19:07
Dan_P3-May-05 19:07 
Generaldefault buttons Pin
cmarmr3-May-05 4:55
cmarmr3-May-05 4:55 
GeneralRe: default buttons Pin
Dan_P3-May-05 19:01
Dan_P3-May-05 19:01 
GeneralJavascript Keyboard Pin
totig2-May-05 22:00
totig2-May-05 22:00 
GeneralRe: Javascript Keyboard Pin
illmatik4-May-05 13:08
illmatik4-May-05 13:08 
GeneralRe: Javascript Keyboard Pin
totig4-May-05 20:29
totig4-May-05 20:29 
QuestionHow to deploy .msi ? Pin
Yeast272-May-05 21:32
Yeast272-May-05 21:32 
GeneralCommon functions Pin
killerspam2-May-05 4:08
killerspam2-May-05 4:08 
Hi guys,

I've used PHP quite a bit before, and I'm now moving over to ASP.

In PHP, I would create a common functions file called functions.php, and use require('functions.php') at the top of every page.

I am having trouble trying to replicate this in ASP.

In a single page scenario, I have this code, which queries a database:

<br />
Dim Conn 	'Create the ADOBD connection object<br />
Dim rs		'Create the recordset object<br />
<br />
set conn = server.CreateObject ("ADODB.Connection")		<br />
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("Rental.mdb")<br />
<br />
set rs = server.CreateObject ("ADODB.Recordset")<br />
<br />
<br />
rs.Open "SELECT [BALANCE] FROM [MEMBER] WHERE [MEMBERID] = " & session("memberID") &"", Conn


So, I created a functions.asp page, and placed all code EXCEPT the rs.open line, into it. That page looks like this:

<%<br />
Function SetupConnection()<br />
<br />
	Dim Conn 	'Create the ADOBD connection object<br />
	Dim rs		'Create the recordset object<br />
<br />
	set conn = server.CreateObject ("ADODB.Connection")		<br />
	Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("Rental.mdb")<br />
<br />
	<br />
	set rs = server.CreateObject ("ADODB.Recordset")<br />
<br />
End Function<br />
%>


I then placed this in the original page, above the rs.open line...

SetupConnection()


When calling the original page, I get:

Object required: ''
/account_main.asp, line 11

Line 11 is the rs.open line.


Am I completely missing the point here? The only thing I can assume is that it's something to do with the scope of variables.
GeneralViewState problem... Pin
brian552-May-05 2:13
brian552-May-05 2:13 
GeneralRe: ViewState problem... Pin
Mike Ellison2-May-05 2:46
Mike Ellison2-May-05 2:46 
GeneralRe: ViewState problem... Pin
brian552-May-05 10:23
brian552-May-05 10:23 
GeneralRe: ViewState problem... Pin
Mike Ellison2-May-05 10:34
Mike Ellison2-May-05 10:34 
Questionhow to decript the data in asp Pin
chandan sharma2-May-05 1:59
chandan sharma2-May-05 1:59 
AnswerRe: how to decript the data in asp Pin
Dan_P2-May-05 14:43
Dan_P2-May-05 14:43 
Questionhow to know the drive drive name by using asp Pin
chandan sharma1-May-05 22:44
chandan sharma1-May-05 22:44 
AnswerRe: how to know the drive drive name by using asp Pin
Dan_P2-May-05 0:08
Dan_P2-May-05 0:08 
GeneralRe: how to know the drive drive name by using asp Pin
chandan sharma2-May-05 0:25
chandan sharma2-May-05 0:25 
GeneralXMLHTTP and PROXY problem Pin
karanba1-May-05 8:12
karanba1-May-05 8:12 
GeneralRe: XMLHTTP and PROXY problem Pin
Dan_P2-May-05 0:13
Dan_P2-May-05 0:13 
Generalset focus Pin
cmarmr30-Apr-05 16:27
cmarmr30-Apr-05 16:27 
GeneralRe: set focus Pin
Mike Ellison2-May-05 2:58
Mike Ellison2-May-05 2:58 
QuestionJavaScript variable from ASP form? Pin
tantiboh30-Apr-05 6:53
tantiboh30-Apr-05 6:53 
AnswerRe: JavaScript variable from ASP form? Pin
Dan_P2-May-05 0:18
Dan_P2-May-05 0:18 
GeneralXML Access Pin
rpussewela29-Apr-05 22:16
rpussewela29-Apr-05 22:16 
Generalgetting variables from one webform to another Pin
cmarmr29-Apr-05 14:56
cmarmr29-Apr-05 14:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.