I am creating a SilkTest script in which am storing a string in a List of String variable
List of STRING FaultDn
This variable reads the string from a file.
FaultDn = ReadFile("C:\FaultDn.txt")
Then I try to connect to SQL database to retrieve a value by providing this string
HSQL hstmnt = DB_ExecuteSql (hdbc, "select Id from openview.dbo.OV_MS_Message where OriginalServiceId like @FaultDn")
But it returns an error
Error: (42000) [Microsoft][SQL Server Native Client 10.0][SQL Server]Must declare the scalar variable "@FaultDn".
Can you please help in correcting this SQL Query in SilkTest Script?
I think you need to change your query to
The difference being at
'{FaultDn}'
. You need to add the curly braces so Silk Test interprets it as a variable name, and the quotes because it is a string literal within the SQL query.What I'm not exactly sure about it whether you're intentionally passing the whole list into the query, if you just want to pass the first line, you should change it to
'{FaultDn[1]}'
.