Data Access From SQL SERVER to Asp.net Application
-
Dear All, I have a question regarding data access from SQL server 2008 to Asp.net 4.0 application... My question is what is the best method to get data from SQL Server, Table, View, Stored Procedure, function.. My Problem, why I am asking this question, I want to access data from Stored Procedures and I have to define parameters on creation time of procedures and have to use them all in asp.net form to access data. But I want to give rights to user, get data with nos of parameter if he wants to use otherwise no filter all data would be displayed... and he has right to use all filters or no filter or whatever that is defined. So in this situation what would you guys recommend to get data from SQL using Stored Procedure, Tables or Views and how is that possible? Thanks in advance for your reply Shuja
-
Dear All, I have a question regarding data access from SQL server 2008 to Asp.net 4.0 application... My question is what is the best method to get data from SQL Server, Table, View, Stored Procedure, function.. My Problem, why I am asking this question, I want to access data from Stored Procedures and I have to define parameters on creation time of procedures and have to use them all in asp.net form to access data. But I want to give rights to user, get data with nos of parameter if he wants to use otherwise no filter all data would be displayed... and he has right to use all filters or no filter or whatever that is defined. So in this situation what would you guys recommend to get data from SQL using Stored Procedure, Tables or Views and how is that possible? Thanks in advance for your reply Shuja
hi Shuja, at its base is all activities when using Parameter Stored Procedure, we must define its parameters simultaneously dengna making its Stored Procedure. using LINQ or the Code definition ConnectionsClass (SqlClient, ODBC, OleDb etc. ..), its all the same to use parameters. but if you want to save the program code, you can make it with a parsing technique parameters such as the example below: in SP,
ALTER PROCEDURE [dbo]. [GET_SALER_ORDER]
(
@ SALESNAME VARCHAR (20)
)
U.S.
SELECT * FROM WHERE TABLE_SALES SALES_NAME LIKE @ SALESNAMEand in its asp.net code, you can call him by implanting code like this:
salesname var = "%" + parsingsalesnamevalue + "%";
var sqlcmd = new SqlCommand ("GET_SALER_ORDER", sqlcon);
sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Parameters.AddWithValue ("@ SALESNAME", salesname);This means, if the value of its parsingsalesnamevalue empty, meaning the application code to call the data without the filter, if its opposite, meaning the application code to filter based salesname. is this what you mean, or you can tell me more detail about your wishes, hope this helps as a prefix you in building your applications