none
Using "addparam", not all parameters are being substituted

    Question

  • I use addparam all the time and it normally work well. I am using VS 2008 as this is an older well established application I am working on.

    I have a routine that takes and runs a SQL script from a list of standard reports, most of the scripts work well apart from a couple that are large and where there are several instances of the parameter. In this case it fails, and looking at what actually gets sent to the database, has the parameters substituted at the beginning of the script but not at the end. I have changed the name of the later parameters but this has no effect. It just appears that the substitution only works in the earlier part of the script.

    The script is some 40K and runs fine outside of VS.

    Anyone have any thoughts?


    Don C

    Tuesday, August 09, 2016 6:28 AM

All replies

  • Hi Don C,

    Could you please tell me what's your project type?

    >>The script is some 40K and runs fine outside of VS.

    Does the error occurred only when running the scripts in your Visual Studio? Could you please provide us the SQL scripts so we could reproduce it in our sides.

    By the way, if your issue is more related to the your SQL Scripts. I suggest you'd better post it our Visual Studio SQL Server forum for better support.

    Thanks for your understanding.

    Best Regards,

    Lake Xiao


    Wednesday, August 10, 2016 2:26 AM
    Moderator
  • Hi Lake

    As I said at the end, the script works fine outside of VS.

    It is a very complex SQL script and would not be of any use without the actual database behind it.

    Smaller scripts work fine. If I use a regex.replace to substitute the values for the @Params instead of using addparam all the parameters are substituted and it equally works fine.


    Don C

    Wednesday, August 10, 2016 1:02 PM
  • Hi Don C,

    Thanks for your quick response.

    >>the script works fine outside of VS.

    Could you please tell me where did you run the script? Did you use ADO.NET?

    If possible, please provide us a simple code so we could better troubleshoot your issue.

    Best Regards,

    Lake Xiao

    Thursday, August 11, 2016 1:42 AM
    Moderator
  • As indicated the issue appears to be related to the size of the SQL script, hence, "simple" SQL does not manifest the issue.

    I am using Regex to substitute the parameters and the routine is working fine. There definitely seems to be a limit with addparam.


    Don C

    Thursday, August 25, 2016 6:27 AM
  • Hi Don C,

    >>There definitely seems to be a limit with addparam.

    If it is a limit with addparam, I suggest you could submit as  a feature request to the Visual Studio team.

    http://visualstudio.uservoice.com/forums/121579-visual-studio .

    The Visual Studio product team is listening to user voice there.

    Best Regards,

    Lake Xiao

    Friday, August 26, 2016 1:23 AM
    Moderator