A Repasky

A Repasky

  • NA
  • 231
  • 183.1k

SQL IN Statement C# Parameter string holding more than one value

Jul 14 2011 3:49 PM
I want to read in a string value from an XML file that holds more that hold more than one group number.  In my SQL script I have 2 lines that use the group number:
        AND AccountsPayable.CoverageGroupCode in (@grpno) 





and



        WHERE dbo.Claims.GroupNbr in (@grpno) 
Then after the script is set to the cmd.CommandText I have: 
cmd.Parameters.AddWithValue("@grpno", groupno);






My XML file is read in fine and the line is:
 <Extract Name="FirstName" Location= "\\xxxxxxx\xxxxxx\Folder" GroupNo="005465','007284">


It runs and does not abort, but no records are found. As you notice on my GroupNo, I do not incude the
leading single quote or the trailing single quote for GroupNo, because it looks like .NET provides them.
When I only have one GroupNo as:
   <Extract Name="AnotherName" Location= "\\xxxxxxx\xxxxxx\Folder" GroupNo="005536">
it works fine. No leading or trailing single quotes are provided.


The lead programmer I am sure wants me to use a parameter and not use a variable in the middle of the SQL
script. I know it will work that way, but I would like to use a parameter. I want to use one program to
run many extracts. If not the lead programmer will want me to have a separate program for each extract
I have many extracts. How can I so this?

Is there a way with .NET and C# to see what exactly what the SQL script is run? If I print out CommandText,
it shows the @grpno in the script and not what is substituted from the XML file.




Thanks ahead of time for any help on this.







arep
 

Answers (1)