1

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?

Diya
  • 143
  • 1
  • 3
  • 13

1 Answers1

1

I think you need to change your query to

HSQL hstmnt = DB_ExecuteSql (hdbc,  "select Id from openview.dbo.OV_MS_Message where OriginalServiceId like '{FaultDn}'")

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]}'.

tehlexx
  • 2,821
  • 16
  • 29
  • Thanks a ton!! It worked. I had tried the curly braces but I missed adding the quotes. – Diya Aug 10 '12 at 07:29
  • Glad I could help. Please remember to accept the answer, and if you found it helpful, I'd also be happy for an up-vote (the little up arrow on near top left). – tehlexx Aug 10 '12 at 11:19
  • Okay. I didn't know about accepting answer. I did that now. I did try doing an up-vote before posting my reply but it says I need 15 reputation to do up-vote :( and I only have 6 now :( – Diya Aug 10 '12 at 12:53