Call a stored procedure from ado.net and pass parameter to it ?

Answer Posted / vagdevi

By using the SQLHelper of Microsoft,
in Business Layer import Microsoft.ApplicationBlocks.Data
and then,
Create properties for the parameters as userid,password
Declare a parameter array of Type SqlParameter as,

SqlParameter[] p=new SqlParameter[2];

p[0]=new SqlParameter("@userid",userid");
p[0].DbType=DbType.String;
p[0].Direction=ParameterDirection.Input;

p[1]=new SqlParameter("@password",password");
p[1].DbType=DbType.String;
p[1].Direction=ParameterDirection.Input;

SqlHelper.ExecuteNonQuery
(ConnetionString,CommandType.StoredProcedure,"StoredProcedur
eName", p);

That's it and call this method in your Presentation Layer

Is This Answer Correct ?    8 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many major types of connection objects in ADO.NET?

827


How to add a check box or a dropdown list to a column in a datagrid?

754


What is the difference in an abstract class and an interface?

745


Define data access layer?

731


What is disconnected data?

789


Explain how to create dynamic gridview?

730


Can you explain how to enable and disable connection pooling?

747


What is the difference between OLEDB Provider and SqlClient?

735


What is ado.net code?

730


What are the core objects of ADO.NET?

801


Which provider is used to connect ms access, oracle, etc…?

753


What is linq and entity framework?

722


What is the use of ADO.NET and XML web services?

807


What is the default Timeout for SqlCommand.CommandTimeout property?

749


What is concurrency? How will you avoid concurrency when dealing with dataset? (One user deleted one row after that another user through his dataset was trying to update same row. What will happen? How will you avoid the problem?)

791