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
What is the relationship between a class and an object? A class acts as a blue-print that explains the properties, states, and behaviors that are common to a number of objects.

I want high skilled C++ programmers Project Description: I want to hire the developer, who are proficient in C/C++ and have experience with STL and work with the data structu

I need a Web Application UI Modernization - Preliminary Technology Assessment We are seeking to overhaul a 10-year old enterprise application, CRM-related as well as web-based t

What is Windows DNA architecture? The Windows Distributed internet Applications Architecture (DNA) is a Microsoft blueprint for scalable, robust, & distributed business softwar

Checking for validity of an expression - C# Program Hello can you please provide me some examples regarding to the Checking for validity of an   expression in C#.

What are advantages of SQL 2000 over SQl 7.0? 1)User-Defined Functions: The User-Defined Functions (UDFs) -- one or moreTransact-SQL statements may be used to encapsulate the

Sorting 2 Arrays & Merging into 1 - C# Program Hello, i didn't find the correct way to implement Array in my project. I am beginner for this language.  Please suggest me some

I need Remote chat Application for desktop Project Description: I want a team of .net experts who will design me a website and a remote desktop chat application as like  live

What are the precautions so that StateServer Mode work properly? Following are some points to remember so that StateServer Mode works properly:- a) StateServer mode session

What is the difference between Authentication and authorization? This is  a tricky question. These two concepts seem altogether same  but there is big  difference. The Authenti