June 22, 2005 at 3:37 am
Hi,
I used "Creating the nwind Virtual Directory" from SQL Server Books Online.
All the steps worked fine. But when i try to test the virtual directory in the browser , i type:
"/nwind?sql=SELECT * FROM Employees FOR XML AUTO&root=root" target=_blank>http://<IISServer>/nwind?sql=SELECT * FROM Employees FOR XML AUTO&root=root" and i press ENTER.
I got an error on the browser "The URL could not be retrieved""
I did help about on my SQL Query Analyser. The Version is SQL 8.00.760
Please help.
Thanks&Regards.
June 22, 2005 at 12:33 pm
an url and it's arguments may not contain spaces or other reserved characters; the argument must be urlencoded:
SELECT+%2A+FROM+Employees+FOR+XML+AUTO&root=root
in .net you can use system.web.httputility.urlencode i think, in asp it's server.urlencode,
if you set your form to METHOD="GET" and you have a <INPUT TYPE="text" NAME="sql"> t this would be done automatically as part of the form's submit functionality.
if you need a function to do it here's a vb6 version you can adapt:
Public Function URLEncode(sRawURL As String) As String
On Error GoTo Catch
Dim iLoop As Integer
Dim sRtn As String
Dim sTmp As String
Const sValidChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz:/.?=_-$(){}~&"
If Len(sRawURL) > 0 Then
' Loop through each char
For iLoop = 1 To Len(sRawURL)
sTmp = Mid(sRawURL, iLoop, 1)
If InStr(1, sValidChars, sTmp, vbBinaryCompare) = 0 Then
' If not ValidChar, convert to HEX and p
' refix with %
sTmp = Hex(Asc(sTmp))
If sTmp = "20" Then
sTmp = "+"
ElseIf Len(sTmp) = 1 Then
sTmp = "%0" & sTmp
Else
sTmp = "%" & sTmp
End If
End If
sRtn = sRtn & sTmp
Next iLoop
URLEncode = sRtn
End If
Finally:
Exit Function
Catch:
URLEncode = ""
Resume Finally
End Function
Lowell
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy