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.
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:
Expand|Select|Wrap|Line Numbers
- <% @ 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
- %>