Wednesday, November 26, 2014

Better approach to execute procedure at Dot Net front end

I have a form built in C#.Net and it has got approx 40 controls, all the controls datavalues comes from sql server database.

Which of the following is a better approach

1. Write one procedure and add all the queries for each controls in the procedure so that they execute sequentially and get result as dataset and finally loop controls and bind with each datatable.



For eg:



connection.Open

DataSet ds = ExecuteProc("SomeProc")

control1.DataSource=ds.Tables(0)

control2.DataSource=ds.Tables(1)

control3.DataSource=ds.Tables(2)

.

.

.

.

connection.Close



2. Write procedure for each control and bind them, but with threading technology so that they execute parallely, but in this case for each procedeure we need to open and close connections for each procedure when executed.



For eg:



all running parallely:



connection.Open

DataSet ds = ExecuteProc("SomeProc1")

control1.DataSource=ds.Tables(0)

connection.Close



connection.Open

DataSet ds = ExecuteProc("SomeProc2")

control2.DataSource=ds.Tables(0)

connection.Close



connection.Open

DataSet ds = ExecuteProc("SomeProc3")

control3.DataSource=ds.Tables(0)

connection.Close



.

.

.

.



Can you help me getting the answer for the proposed methods or is there any other better approach to achieve this at faster rate?



Thanks in advance



With Regards, Yusuf


No comments:

Post a Comment