Getting "System Error" when trying to execute query

Deepthiv

Active member
Joined
Oct 3, 2005
Messages
39
Programming Experience
3-5
I am getting System Error when trying to execute below query from VB.NET

QueryCmd.CommandText = "select substring(substring(convert(varchar(512),textdata) ," & _
"charindex('exec', convert(varchar(512),textdata))+5, 512),1," & _
"case" & _
"when charindex(' ', substring(convert(varchar(512),textdata)," & _
"charindex('exec', convert(varchar(512),textdata))+5, 512)) = 0 THEN" & _
"len(substring(convert(varchar(512),textdata)," & _
"charindex('exec', convert(varchar(512),textdata))+5, 512))" & _
"else" & _
"charindex(' ', substring(convert(varchar(512),textdata), " & _
"charindex('exec', convert(varchar(512),textdata))+5, 512))" & _
"end) as proc_name from [" + strFilename + "]"


Dim dr As SqlDataReader

dr = QueryCmd.ExecuteReader()
MsgBox("Succeeded...1")

but when trying to execute from sqlserver - its working????/

Table is created from Profiler Trace file and i am trying select query on tht

Can some one help please...??

--Deepthi. V
 
Hey Deepthiv,

Just at a glance, I think you need to check for missed spaces. For example:
VB.NET:
"else" & _
 "charindex(' '

will result in a string "elsecharindex(' '"

so you can change it to
"else " & _

This occurs a few times in the query above.

Hope this helps.
 
Back
Top