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
Set up a FTP File Server and active FTP File Transfer using VB.NET The Job Description is as given: 1. Manually set up a FTP file server on a remote server. 2. Manually ad

how to connect login page with my database and check the values with the database.

What is a Hash Table? You can access an array using the INDEX value of that array, but how many times you know the real value of the index. The Hashtable provides a way of acce

Project Description: I am preparing a speech recognition program and need a quick code to get it done I am seeking for someone to create a Gmail API that can get subject, and co

What are the different elements in Functions points? 1) Internal Logical Files (ILF): Following are some points to be noted for ILF:- The ILF are logically related d

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

Project Description: My project is to construct for me an application that emulates the http requests made in a webapp. It will need a lot of dedication and skill in C#,.net,

Problem: (a) Explain the difference between these two lines of ASP codes: (b) The VBScript language includes some built-in functions which are often used in ASP co

What is a cloud? A cloud is a combination of hardware, storage, networks, services, and interfaces that helps in delivering computing as a service. It has generally three users

I want Workflow Designer (HTML5) Project Description: I am seeking an HTML5 designer for a custom workflow tool. It should have drop and drag functionality. Saving it as XML