How do we provide parameters to the stored procedures?, DOT NET Programming

The ADO.NET gives the SqlCommand object which gives the functionality of executing the stored procedures.

CREATE PROCEDURE SelectByEmployee @FirstName nvarchar(200) AS

Select FirstName from Employees where FirstName like @FirstName + '%'

CREATE PROCEDURE SelectEmployee AS

Select FirstName from Employees

If txtEmployeeName.Text.Length = 0 Then

objCommand = New SqlCommand("SelectEmployee")

Else

objCommand = New SqlCommand("SelectByEmployee")

objCommand.Parameters.Add("@FirstName", Data.SqlDbType.NVarChar, 200)

objCommand.Parameters.Item("@FirstName").Value =

txtEmployeeName.Text.Trim()

End if

In the sample above not much has been modified only that the SQL is moved to the stored procedures. There are 2 stored procedures one is "SelectEmployee" which selects all employees and the other is "SelectByEmployee" that returns employee name starting with the specific character. As you can see to give parameters to the stored procedures we are using the parameter object of the command object. In such type of question interviewer expects two simple answers one is that we use command object to execute the stored procedures and the parameter object to give  parameter to the stored procedure. The sample above is provided only for getting the actual feel of it.

Posted Date: 9/24/2012 2:40:48 AM | Location : United States







Related Discussions:- How do we provide parameters to the stored procedures?, Assignment Help, Ask Question on How do we provide parameters to the stored procedures?, Get Answer, Expert's Help, How do we provide parameters to the stored procedures? Discussions

Write discussion on How do we provide parameters to the stored procedures?
Your posts are moderated
Related Questions
how we can display a alphabets by identifies an image and if its different than show someother alpbabets.

Can you give a practical implementation of FAÇADE patterns? The Façade pattern sits on the top of lot of the subsystems & makes access easy to interfaces of these subsystems. T


Explain different types of XML Application Programming Interface (API). The following are two main parts of XML parsers: Tree-based API - Compiles an XML document into a tre

Develop Outlook Add-In for all versions I need simple code for Outlook(express,2003,2007,2010,2013) Add-In with functionality to repeatedly send CC to the specified email(s), th

Classic ASP I am seeking somebody to develop a web-based user registration screen (List, New, Modify and Delete) preferably using classic ASP framework. The coding must be st

What is XPath? XPath stands for XML Path. It is a language used to access dissimilar parts of an XML document, such as elements and attributes.

What is serialization, how it works in .NET? Serialization is when you persist the state of an object to a storage medium so an exact copy can be re-created at a later stage. S

What are major difference between classic ADO and ADO.NET ? Some major differences between the classic ADO & ADO.NET are as follows: 1) As in the classic ADO we had server a

This assignment will have you create a simple static web page. It should look something like this: The colored boxes do not represent colors I want to see, make it look nic