How to pass a switch value to filter data

I have a stored procedure on a SQL server to display some data in a vb.net application. can i just change my procedure? how to pass the value of the switch to display data based on the selected switch without changing the VB code and without adding a new parameter in SQL, can this be done? these are my parameters.

ALTER PROCEDURE [dbo].[LMS_Report] @deptID varchar(10), @month int, @year int, @startIndex int, @pageSize int, @generateData int, @totalRecords int OUTPUT 

Sorry, this is the first time I use vb.net

+5
source share
3 answers

I can think of two solutions for this:

1- using ajax, since you cannot change the code, you can only update .aspx files and add an AJAX call after loading the page to load your switch using the same procedure you mentioned earlier .. this solution is completely isolated since you do not need any changes to the vb.net code

2- Remove the Inheritance tag from .aspx and add:

<script runat="server> rewrite the whole page code here </script>

In fact, you are redoing the whole page in the second solution.

+2
source

Follow the instructions

1) Get the value of the switch when you click on it and save it in a variable.

2) After that, you can pass the values ​​to the stored procedure during sqlcommand execution.

, eg

1) the value for the radio button is "red", this value is stored in the line "RadioButtonValue".

2) pass this RadioButtonValue to the SQL stored procedure using cmd.

cmd.Parameters.AddWithValue ("@RadioButtonValue", RadioButtonValue) .

@RadioButtonValue is a variable declared in stored procedures.

else link to the following link

http://www.aspsnippets.com/Articles/Pass-Table-Valued-Parameters-to-Stored-Procedure-from-Code-Behind-using-ADONet-C-and-VBNet.aspx

+2
source

I have my own solution: 1. The separation parameter, which is of type varchar, for example, below:

 Declare @condition varchar(20) = null SET @condition = SUBSTRING(RTRIM(@deptID), LEN(RTRIM(@deptID) + '|')-1,LEN(RTRIM(@deptID))) SET @deptID = SUBSTRING(RTRIM(@deptID), 0, PATINDEX('%|%',RTRIM(@deptID))) SET @deptID = RTRIM(@deptID) 
2. get the value of the switch from the aspx page 3. add the condition to the stored procedure:

 IF(@condition='1') BEGIN --your statement here END ELSE BEGIN --your statement here END 
  1. reload dll into IIS manager
0
source

All Articles