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
Web Service based application: Aims and Objectives Classics Online is a Web-based book and music retailer specialising in pre-1980s hardback

What is denormalization? The Denormalization is the process of putting one fact in numerous places (i.e. the vice-versa of normalization). Only one valid reason exists for deno

Live Chat Similar to Alibaba seller/ buyer chat Project Description: I want someone to design and implement for us a live chat program that will be used on our ecommerce webs

What is the difference between Shadowing and Overriding? The main basic difference between shadowing and overriding are as follows:- 1) The Overriding redefines only the imp

Connect a Software Application to a Database Backend Acquire the knowledge and develop the skills needed to prototype an end user application using a rapid application dev

Develop a iPhone and Android mobile game Project Description: I am seeking a developer to create a mobile game for me. I need an endless runner game with simple controls. The

I need to create the subsequent iOS App/ iPhone (to be followed by Android & other platforms). Version 1.0--Users can: --Find events based on proximity/zipcode*/ location

What is XSLT? The XSLT is a rule based language used to transform XML documents into other file formats. The XSLT are nothing but generic transformation rules which can be appl

We have a web based program completed with .NET C# and Microsoft SQL Server. There are some reports requires to be created. Required Skills. - High Proficiency in .NET C#

What is ReaderWriter Locks? You may want to lock the resource only whenever data is being written and permit multiple clients to parallel read data when data is not being updat