Conditional stored procedure

Hi Experts,

How can I write a stored procedure for this.

If All_Opportunity_Clicked = False Then
                'Show only personal opp.
                If ddlCustomer.SelectedValue = "---Select Customer---" Then
                    sql = "Select * from JOBDETAILS where JobOrOpportunity='O' and OppCreatedBy=" & Session("EmpID")
                Else
                    sql = "Select * from JOBDETAILS where JobOrOpportunity='O' and OppCreatedBy=" & Session("EmpID") & " and JOBDETAILS.CustomerID = " & ddlCustomer.SelectedValue
                End If
                GVViewOpp.Columns(7).Visible = False
            Else
                'The admin can view all the opportunities. Including the private ones. If he wants to see the private opp. then he will click the check box.
                If chkShowPrivateOpp.Checked = True And (Session("Admin") = "Y") Then
                    If ddlCustomer.SelectedValue = "---Select Customer---" Then
                        sql = "Select * from JOBDETAILS where JobOrOpportunity='O' "
                    Else
                        sql = "Select * from JOBDETAILS where JobOrOpportunity='O' and JOBDETAILS.CustomerID = " & ddlCustomer.SelectedValue
                    End If
                Else
                    'If the person is not admin then show his own opp. and all the public opp
                    If ddlCustomer.SelectedValue = "---Select Customer---" Then
                        sql = "Select * from JOBDETAILS where JobOrOpportunity='O' and (OppCreatedBy=" & Session("EmpID") & " or PrivateOrPublic ='PB') "
                    Else
                        sql = "Select * from JOBDETAILS where JobOrOpportunity='O' and (OppCreatedBy=" & Session("EmpID") & " or PrivateOrPublic ='PB') and " & _
                              "JOBDETAILS.CustomerID = " & ddlCustomer.SelectedValue
                    End If
                End If
           End If

Open in new window


Thanks in advance.
Sql.txt
RadhaKrishnaKiJayaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

plusone3055Commented:
it looks like to me that what you are looking for is a Stored procedure to fire off certain SQL based on selections from drop-down menus and data entered in textboxes inside your application.

This can be done,  but not knowing all the names of all the controls inside your applicaiton it would take someone from here a long time.

there are many many step by step tutorials to accomplish this. I cannot post links to them as they belong to competing websites and that would violate EE policy.

However if you were to google

sql stored procedure based on vb net value vb.net

you would find all the information you need to make it happen :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RadhaKrishnaKiJayaAuthor Commented:
I will look at it.

Thanks.
0
RadhaKrishnaKiJayaAuthor Commented:
Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.