Hi,
I have a table which has links at the top of each column to sort by. I am aware that this opens up the risk of SQL injection as someone can put whatever they want in the URL.
Am I correct in thinking this is a foolproof way of stopping it or are there still potential problems?
Thanks very much
Ed
<%
sort=Request.QueryString("sort")
Select Case sort
Case "cRouteName ASC"
sort = "cRouteName ASC"
Case "cRouteName DESC"
sort = "cRouteName DESC"
Case "dtDictEnd ASC"
sort = "dtDictEnd ASC"
Case "dtDictEnd DESC"
sort = "dtDictEnd DESC"
Case "nPriority ASC"
sort = "nPriority ASC"
Case "nPriority DESC"
sort = "nPriority DESC"
Case "cAuthorName ASC"
sort = "cAuthorName ASC"
Case "cAuthorName DESC"
sort = "cAuthorName DESC"
Case "cDeptName ASC"
sort = "cDeptName ASC"
Case "cDeptName DESC"
sort = "cDeptName DESC"
Case Else
sort = "cRouteName ASC"
End Select
'Execute the SQL. Select everything from jobs where the status is U and order by whatever column we have
'clicked on.
TBL.Open "SELECT * FROM Jobs WHERE cStatusChar='U' ORDER BY " & sort, DB
%>
I have a table which has links at the top of each column to sort by. I am aware that this opens up the risk of SQL injection as someone can put whatever they want in the URL.
Am I correct in thinking this is a foolproof way of stopping it or are there still potential problems?
Thanks very much
Ed
<%
sort=Request.QueryString("sort")
Select Case sort
Case "cRouteName ASC"
sort = "cRouteName ASC"
Case "cRouteName DESC"
sort = "cRouteName DESC"
Case "dtDictEnd ASC"
sort = "dtDictEnd ASC"
Case "dtDictEnd DESC"
sort = "dtDictEnd DESC"
Case "nPriority ASC"
sort = "nPriority ASC"
Case "nPriority DESC"
sort = "nPriority DESC"
Case "cAuthorName ASC"
sort = "cAuthorName ASC"
Case "cAuthorName DESC"
sort = "cAuthorName DESC"
Case "cDeptName ASC"
sort = "cDeptName ASC"
Case "cDeptName DESC"
sort = "cDeptName DESC"
Case Else
sort = "cRouteName ASC"
End Select
'Execute the SQL. Select everything from jobs where the status is U and order by whatever column we have
'clicked on.
TBL.Open "SELECT * FROM Jobs WHERE cStatusChar='U' ORDER BY " & sort, DB
%>