Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Access Custom Function in ASP

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,3129
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Access Custom Function in ASP
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Access Custom Function in ASP - 5/26/2005 4:16:37 AM   
  acowboi

 

Posts: 6
Score: 0
Joined: 5/26/2005
From: Canada
Status: offline
Hi,

I am having problems on an asp page. Basically this page is pulling a recordset from an Access database BUT on 1 field in the recordset I need to convert the data using a custom function on the database.

For example:

In the database I have a function:
Function SQR(d as double) as Double
SQR = d * d
end function


In the ASP my SQL code is like:
"select firstname,lastname, SQR(age) from employee"

On the ASP page it is complaining that the SQR function is undefine. How can I avoid this problem?

Thanks,

Andrew
 
 
Post #: 1
 
 Re: Access Custom Function in ASP - 5/26/2005 5:00:13 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear acowboi,
Try declaring the function in the ASP page again

(in reply to acowboi)
 
 
Post #: 2
 
 Re: Access Custom Function in ASP - 5/26/2005 5:40:39 AM   
  acowboi

 

Posts: 6
Score: 0
Joined: 5/26/2005
From: Canada
Status: offline
Hi VBS,

I have tried that to no success. The exact error message I received for a test is:
Microsoft JET Database Engine (0x80040E14) Undefined function 'SQRt' in expression. /test/testfunction.asp, line 16

The code for test page is:
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="../Connections/dbConnections.asp" -->
<%
Function SQRt(d)
SQRt = d * d
end function


Dim Recordset1

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = CON_REGULAR_SEASON
Recordset1.Source = "SELECT tblMatchCard.MatchID,SQRt([RunsScored]) AS SQRrun, tblMatchCard.RunsScored FROM tblMatchCard;"
Recordset1.CursorType = 3
Recordset1.CursorLocation = 3
Recordset1.Open()

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
Helllo
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>

Hope you can help.

Regards,

Andrew

(in reply to acowboi)
 
 
Post #: 3
 
 Re: Access Custom Function in ASP - 5/31/2005 12:43:04 AM   
  acowboi

 

Posts: 6
Score: 0
Joined: 5/26/2005
From: Canada
Status: offline
No further comments on this.

Please and thanks

AcoWboI

(in reply to acowboi)
 
 
Post #: 4
 
 Re: Access Custom Function in ASP - 5/31/2005 1:08:09 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear acowboi,
I am working on it, just give me some time

(in reply to acowboi)
 
 
Post #: 5
 
 Re: Access Custom Function in ASP - 6/6/2005 12:29:12 AM   
  acowboi

 

Posts: 6
Score: 0
Joined: 5/26/2005
From: Canada
Status: offline
Hi Guys,

Any proposed soln for this?

Thanks,

Andrew

(in reply to acowboi)
 
 
Post #: 6
 
 Re: Access Custom Function in ASP - 6/6/2005 10:02:37 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Dear acowboi,
Try using this way of connecting to the database:

set objcon=server.CreateObject("ADODB.Connection")
objCon.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("/db.mdb")
objCon.Open
objCon.BeginTrans
set objrs = server.CreateObject("ADODB.Recordset")
set objRs.ActiveConnection =objcon
objCon.CommitTrans
objRs.Open "SELECT tblMatchCard.MatchID,SQRt([RunsScored]) AS SQRrun, tblMatchCard.RunsScored FROM tblMatchCard;"


Hope this helps

Best regards
Firas S Assaad

(in reply to acowboi)
 
 
Post #: 7
 
 Re: Access Custom Function in ASP - 6/9/2005 1:17:19 AM   
  acowboi

 

Posts: 6
Score: 0
Joined: 5/26/2005
From: Canada
Status: offline
Thanks for the response VBS but I received the same message "Undefined function 'SQRt' in expression."

(in reply to acowboi)
 
 
Post #: 8
 
 Re: Access Custom Function in ASP - 6/9/2005 5:22:05 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
I am afriad i am out of ideas, and i promise if i get anything about ur problem, u will be the first to know...
Good Luck

(in reply to acowboi)
 
 
Post #: 9
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Access Custom Function in ASP Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts