I'm new to SQL and am getting an exception on my webpage when I have an argument to my SQL DB that has spaces in it.
Basically, the page is being passed a name like "Name with spaces", which is being sent as templatename: (in VB)
CODE
ra = New SqlDataAdapter("exec sp_GetTemplateByName '" & templatename & "'", TestStatConn)
ra.Fill(dt)
The exception gets thrown at this line only for names that have spaces, not if a templatename is passed like "name_without_spaces". The exception is
CODE
System.IndexOutOfRangeException: There is no row at position 0.
CODE
ret &= "<td><span style=""color:#a9a9a9"">" & CheckForNullVal(dt.Rows(0).Item("lastchange")) & "</span></td>"
The sp_GetTemplateByName:
CODE
Select
..stuff..
from tbl_checklist_templates
where templatename=@TEMPLATENAME
order by stepnumber
Can anyone shed some light on what's going on here?
This post has been edited by cdietschrun: 26 Jun, 2009 - 05:54 AM