Dynamic Command Building
Posted on 2005-04-12
I'm using the application blocks from Microsoft to make it easier to execute my database related commands in C#.net. I'm trying to write a generic function that populates a datagrid based on these application blocks.
WHen it comes time to get the data to bind to the grid, I use:
// Call stored procedure to get back field names from specific table
DataSet ds = SqlHelper.ExecuteDataset(
What if I wanted to tack on a variable number of parameters at the end of the above command? In other words, what if I needed to send two or three parameters to the stored proc instead of just one? I've created an array of sql parameters, but how would I build it onto the above command? Ideally, I would be able to execute a string like I can in Java. Can this be done in C#?
I guess my other option is to not use application blocks in this case and just build everything from scratch, thereby adding the flexbility I need. Any ideas?