M
mjpdatadev
I have a few sprocs and I want to create a generic handler for them.
Basically, I want to call any sproc and leave it up to the developer
to know the parameters. To keep it simple, I would like to do it so
that the only thing that the developer has to know is the appropriate
datatype and NOT the name of the param.
So, what I am trying to do is this...
Right now, we do it this way (this works, of course):
sqlComm.CommandType = CommandType.StoredProcedure;
sqlComm.Parameters.AddWithValue("@SLast", "EmpLastName");
sqlComm.Parameters.AddWithValue("@SFirst", "EmpFirstName");
SqlDataReader sqlReader = sqlComm.ExecuteReader();
I want to be able to do it something like this (hiding the param
names):
sqlComm.CommandType = CommandType.StoredProcedure;
sqlComm.Parameters[0].Value = "EmpLastName";
sqlComm.Parameters[1].Value = "EmpFirstName";
// With this method the developer has to know the sprocs he wants to
call and
// the datatypes of the param.
SqlDataReader sqlReader = sqlComm.ExecuteReader();
Has anyone done this before?
As an alternative, is it possible to get the metadata of a sproc to
find the param names?
Thanks,
Mark
Basically, I want to call any sproc and leave it up to the developer
to know the parameters. To keep it simple, I would like to do it so
that the only thing that the developer has to know is the appropriate
datatype and NOT the name of the param.
So, what I am trying to do is this...
Right now, we do it this way (this works, of course):
sqlComm.CommandType = CommandType.StoredProcedure;
sqlComm.Parameters.AddWithValue("@SLast", "EmpLastName");
sqlComm.Parameters.AddWithValue("@SFirst", "EmpFirstName");
SqlDataReader sqlReader = sqlComm.ExecuteReader();
I want to be able to do it something like this (hiding the param
names):
sqlComm.CommandType = CommandType.StoredProcedure;
sqlComm.Parameters[0].Value = "EmpLastName";
sqlComm.Parameters[1].Value = "EmpFirstName";
// With this method the developer has to know the sprocs he wants to
call and
// the datatypes of the param.
SqlDataReader sqlReader = sqlComm.ExecuteReader();
Has anyone done this before?
As an alternative, is it possible to get the metadata of a sproc to
find the param names?
Thanks,
Mark