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 are runtime services? Runtime services having of predefined and user-defined classes that are available to the workflow runtime engine during implementation to customize t

What is an activity? In Windows Workflow Foundation 4.0, an activity is the basic unit of composition and implementation of a workflow. Each activity in a workflow consists of

I need to Develop a real state website We want a programmer who can create a website using html5, css3, jQuery, php, MySQL. All connected to a CRM to accomplish all the informat

UDP Based, Data Transfer Server/ Client in .NET C# Project Description: We require the Network Level Functionalities (NLFs) of a Server/ Client for transferring data among tw

Assembly: 1) Assembly is a unit of deployment such as EXE or a DLL. 2) An assembly consists one or more files (dlls, exe's, html files etc.),& represents a group of resources,

What is a class? A class explains all the attributes of objects, as well as the methods that execute the behavior of member objects. It is a comprehensive data type, which show

Project Description: We want to prepare a package forwarding website. Package forwarding refers to a service where US forwarder provides International shoppers with a US address

CRM and Shaerpoint We are using 365+ CRM in the cloud for QuattroCitta at the moment which we will migrate to our own private cloud in six months (project part 2). Within ShareP

Explain Interface? An interface is not a class. It is an entity that is explained by the word Interface. An interface has no implementation; it only has the signature or in oth

Among the items that are related to the implementation of an application for automation of processes, are shown as follows: a) The online patient registry through which patients