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
I have to develop a Google Map Fix .NET Site on Android(maybe Cross Browser issue) Project Description: A developer has implemented a characteristic which involves data from

I need a program that mimics the similar functionality as the link below. Program must have a unique user interface. Must add source code, installer, and of course a nice user i

Bug Correction and Prediction Project Description: The project is about the prediction of bugs and resolves the bug in the sample program using costriage algorithm. You have

Question: (a) Write extract codes to show the structure of the Global.asax file. (b) Outline four classes that allow you to work with File Streams. (c) When working with

How can we connect to Microsoft Access, Foxpro , Oracle etc ? The Microsoft provides System.Data.OleDb namespace to communicate with the databases such as Oracle, scess  etc. I

Howto create a simple stylesheet for a web application

What does a break statement do in the switch statement? The switch statement is a selection control statement that is used to handle many choices and transfer control to the ca

What is "Common Type System" (CTS)?  CTS define all of the basic types that can be used  in the .NET Framework and the operations performed on those type. All this time we have

What is different overloading and overriding, please explain

What is shadowing? When 2 elements in a program have similar name, one of them can hide and shadow the one. Therefore in such cases the element which shadowed the main element