You must Sign In to post a response.
  • Category: .NET

    How to Deal Too many parametrs to function

    In my project , one (SQL) table contains 18 parameters .

    I have to insert this data , and to pas this data to SQL query, through function , I have to pass each column data as a Parameter to function . i.e. 18 Parameters .

    I want to remove this , but how to pass data from UI to BAL , DAL.

    I want to avoid again and again creating 18 Parameter Functions .
  • #762053
    You can use for loop and indexing in your field like this


    for(int i =0;i<table.columns.count;i++)
    // Add your parameter para[i];

    Name : Dotnet Developer-2015
    Email Id :

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762056
    Hi Jeevan,

    What about your database table structure.?

    How many fields are there in your table structure..?

    Are you going to insert all the fields (or) selected fields..?

    If you want to insert selected fields alone then other than passing parameters.

    We can able to reduce few fields by inserting them directly from procedure itself.

    EX: CreatedDate ,ModifiedDate fields.

    While Insert those records you can use GetDate() function in SQL server, this will reduce the parameter count. like that you need to do as max as from SQL side insertion.

    If everything is mandatory to update dynamically then there is no option you need to pass all the parameters without fail in SP, BAL, DAL, and Code also.

    Hope this information will helpful to you...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #762064
    Thanks for your reply's

    If I Use Array then their is restriction to maintain same sequence as Columns.

    If All Fields are from user input then how to use SQL getData() ?

  • Sign In to post your comments