I have an ASP page that generates XML after querying an MS Access Datbase. But when I upload it to a SharePoint 2007 server, I am not allowed to upload .asp files. So I named it .aspx and uploaded it successfully. When hitting the .aspx page I just uploaded, I get an ERROR page:
What can I do to make it work? Will I have to convert my classic ASP code to ASP .NET code? If so, can someone help me convert my ASP code to ASP .NET?
Here's the ASP code for xmlgetdata.asp:
Thank you in advance for your help guys!!
Error
An error occurred during the processing of /sites/mysite/portal/xmlgetdata.aspx . Code blocks are not allowed in this file.
Troubleshoot issues with Windows SharePoint Services.
An error occurred during the processing of /sites/mysite/portal/xmlgetdata.aspx . Code blocks are not allowed in this file.
Troubleshoot issues with Windows SharePoint Services.
What can I do to make it work? Will I have to convert my classic ASP code to ASP .NET code? If so, can someone help me convert my ASP code to ASP .NET?
Here's the ASP code for xmlgetdata.asp:
Code:
<% @ Language="VBScript" %>
<%
' Declare all variables.
Option Explicit
Dim objCN,objRS,objField
Dim strSQL,strCN
Dim strName,strValue
' Buffer and output as XML.
Response.Buffer = True
Response.ContentType = "text/xml"
' Start our XML document.
Response.Write "<?xml version=""1.0""?>" & vbCrLf
Response.Write "<?xml:stylesheet type=""text/xsl"" href=""xmlrender.xsl""?>" & vbCrLf
' Set SQL and database connection string.
strSQL = "SELECT * FROM SubNav"
strCN = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=\\server01\mydb1.mdb"
' Open the database connection and recordset.
Set objCN = Server.CreateObject("ADODB.Connection")
objCN.Open strCN
Set objRS = objCN.Execute(strSQL)
' Output start of data.
Response.Write "<DATABASE>" & vbCrLf
' Loop through the data records.
While Not objRS.EOF
' Output start of record.
Response.Write "<RECORD>" & vbCrLf
' Loop through the fields in each record.
For Each objField in objRS.Fields
strName = objField.Name
strValue = objField.Value
If Len(strName) > 0 Then strName = Server.HTMLEncode(strName)
If Len(strValue) > 0 Then strValue = Server.HTMLEncode(strValue)
Response.Write "<FIELD>" & vbCrLf
Response.Write "<NAME>" & strName & "</NAME>" & vbCrLf
Response.Write "<VALUE>" & strValue & "</VALUE>" & vbCrLf
Response.Write "</FIELD>" & vbCrLf
Next
' Move to next record in database.
objRS.MoveNext
' Output end of record.
Response.Write "</RECORD>" & vbCrLf
Wend
' Output end of data.
Response.Write "</DATABASE>" & vbCrLf
%>
Comment