BenSCooper
Programmer
Dear All,
Any advice on this issue would be most appreciated as I really don't know what to do for the best.
As part of a wider project I'm writing code\stored procedures to perform the simple task of inserting a row into a SQL table.
I have my SP which accepts a param for each field in the table (approx 100 fields).
I'm looking to design a function which will pass these params to the SP. My question is, how should I best be passing these params from the Business Layer to the Data access function? My thoughts so far:
1) Have the function accept a param for each param that the SP is expecting e.g.
public Function (param1, param2,...param100)
However, it seems unwieldy forcing users to type in 100 params whenever they wish to use this function.
2) Create a class with the parameters defined and pass an instance of the class to the function.
However, I'm concerned that this is just giving me another object to update whenever the database changes, just so I can pass data to the data access function.
3) Run a SELECT query on the table in question to return a blank datatable object. The datatable can then be populated referencing the named columns for clarity and passed to the function.
However, I'm concerned that in my efforts to make the ongoing maintenance easier I'm suggesting a horribly inefficient method here.
To add to the problem I'm currently coding in Access 2003. Phase 1 is moving the tables to SQL 2005. Phase 2 will involve a front end rewrite in .Net. However, I would like to begin moving towards a .Net style of coding for elements I'm rewriting in phase 1 to make my life easier in the coming months.
Any advice on Access or .Net solutions to this query would really help me out as I can't get a clear picture of what the best practice here should be.
Thanks
Ben Cooper
Any advice on this issue would be most appreciated as I really don't know what to do for the best.
As part of a wider project I'm writing code\stored procedures to perform the simple task of inserting a row into a SQL table.
I have my SP which accepts a param for each field in the table (approx 100 fields).
I'm looking to design a function which will pass these params to the SP. My question is, how should I best be passing these params from the Business Layer to the Data access function? My thoughts so far:
1) Have the function accept a param for each param that the SP is expecting e.g.
public Function (param1, param2,...param100)
However, it seems unwieldy forcing users to type in 100 params whenever they wish to use this function.
2) Create a class with the parameters defined and pass an instance of the class to the function.
However, I'm concerned that this is just giving me another object to update whenever the database changes, just so I can pass data to the data access function.
3) Run a SELECT query on the table in question to return a blank datatable object. The datatable can then be populated referencing the named columns for clarity and passed to the function.
However, I'm concerned that in my efforts to make the ongoing maintenance easier I'm suggesting a horribly inefficient method here.
To add to the problem I'm currently coding in Access 2003. Phase 1 is moving the tables to SQL 2005. Phase 2 will involve a front end rewrite in .Net. However, I would like to begin moving towards a .Net style of coding for elements I'm rewriting in phase 1 to make my life easier in the coming months.
Any advice on Access or .Net solutions to this query would really help me out as I can't get a clear picture of what the best practice here should be.
Thanks
Ben Cooper