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 can COM Components use in .NET? The .NET components can communicate with COM using RCW (Runtime Callable Wrapper). The ways with which you can generate RCW are as shown bel

What is the difference between Server.Transfer and response.Redirect? The difference  between the Server.Transfer and the response.Redirect them are as follows:- 1)Response.

Professional TELERIK Bind MS ACCESS Required: 1. Including custom fields to the Schedule. 2. Schedule Calendar Sync with Outlook 3. Selecting display in Schedule res

What is a candidate key? A table may have more than one combination of columns that could uniquely identify the rows in a table; every combination is a candidate key. During th

What are design patterns? The Design patterns are recurring solution to the recurring problems in the software architecture. There are 3 basic classification of patterns Behavi

What is UDDI? The Full form of the UDDI is Universal Description, Discovery and Integration. The directory that can be used to publish and discover public Web Services. If you

What is Multi-threading? Multi-threading process forms the subset of Multi-tasking. Inspite of having to switch between programs this feature switches between different parts o

What is a gateway or Router? A node that is linked to two or more networks is commonly called as router or Gateway. It generally forwards message from single network to another

What is ViewState? The Viewstate is built-in structure for automatically retaining the values among the multiple requests for the similar page. The viewstate is internally main

I need very easy project in metatrader Project Description: I have 3 indicators.... ADX, emas crossover and macd crossover! They are all signals, arrows! But i would like to