Can stored procedures accept optional parameters?
I am using an ADP in Access2k against an SQL Server 2k database.
I am trying to build a form that allows users to query a particular table in my database. What I would like is for them to be able to select from among 5 criteria to use in their search. I have the form set up and it even works by building an SQL string that starts out with a base string like:
strSQl = "Select * From MyTable Where "
And then based on the criteria they selected it will tack on more SQL like so:
strSQL= strSQL & "Criteria1 = 'FooShnicken'"
and so forth for each criteria. I then take this SQL string and pass it to a little module I found somewhere called InstantRst. InstantRst works great. You just pass it an SQL string and it builds the ADODB recordset and passes it back.
Well the problem is that InstantRst works great on my machine because I am on a Windows Integrated Security connection. My users around the office are not in the workgroup so to use this little helpful module I have to code my password right into it. Needless to say I don't want to do this.
So I went all over my code and anywhere I had InstantRst running I converted the SQL into a stored proc and called it that way using ADO. That all works fine but this is a tougher cookie because I don't want to build a stored proc for each scenario.
Can stored procedures accept optional parameters?
Or could I pass in blank parameters and then test for them using conditional statements in the stored proc?
Any suggetions would be greatly appreciated.
I am using an ADP in Access2k against an SQL Server 2k database.
I am trying to build a form that allows users to query a particular table in my database. What I would like is for them to be able to select from among 5 criteria to use in their search. I have the form set up and it even works by building an SQL string that starts out with a base string like:
strSQl = "Select * From MyTable Where "
And then based on the criteria they selected it will tack on more SQL like so:
strSQL= strSQL & "Criteria1 = 'FooShnicken'"
and so forth for each criteria. I then take this SQL string and pass it to a little module I found somewhere called InstantRst. InstantRst works great. You just pass it an SQL string and it builds the ADODB recordset and passes it back.
Well the problem is that InstantRst works great on my machine because I am on a Windows Integrated Security connection. My users around the office are not in the workgroup so to use this little helpful module I have to code my password right into it. Needless to say I don't want to do this.
So I went all over my code and anywhere I had InstantRst running I converted the SQL into a stored proc and called it that way using ADO. That all works fine but this is a tougher cookie because I don't want to build a stored proc for each scenario.
Can stored procedures accept optional parameters?
Or could I pass in blank parameters and then test for them using conditional statements in the stored proc?
Any suggetions would be greatly appreciated.