.NET FAQs Unleashed!
Skip Navigation Links
Interview questions on Design Patterns in .NET
ASP.NET Ajax Interview Questions
Interview questions related to security
C# Interview Questions
ASP.NET Interview Questions
Interview Questions in ASP.NET 2.0
Articles at dotnetuncle.com
Skip Navigation Links
OOPs questions in .NET
Questions on .NET Framework
ADO.NET Interview Questions
Short Answer questions in .NET
Frequently asked differences in .NET
Important commonly used Acronyms in .NET
MS SQL, Oracle SQL Interview Questions
 
    
Dotnetuncle's Tip:

  A value type variable cannot be null. For example: int x = null; will throw a compile time error. However, if required, nullable types can be created for value types by using the ? Symbol. Example: int? y = null;

    

How to run a stored procedure from .NET code?

Use the Command object and its ExecuteNonQuery method to run a DDL or DCL statement of SQL. First, create a connection object and a command object, and configure these objects for the statement you wish to execute. Open the database connection. Call ExecuteNonQuery on the command. Close the connection.

Example
Suppose we have to insert FirstName into a table t_Employees. Our Store procedure is:

Create Procedure dbo.InsertFirstName
(
@FirstName varchar(30)
)
as
Insert Into t_Employees values (@FirstName)

VB.NET code below, to pass FirstName to this Stored Procedure

Dim cmRunProc as New SqlCommand("dbo.InsertFirstName", objCon)
cmRunProc.CommandType = CommandType.StoredProcedure
cmRunProc.Parameters.Add("@FirstName", txtFirstName.Text)
objCon.Open()
cmdRunProc.ExecuteNonQuery()
objCon.Close()

ADO.NET  Connection Object  Command Object  SelectCommand   SqlCommandBuilder  DataView  DataRelation  Diffgram  Typed DataSet  Call Stored Procedure



More Interview Questions...
Skip Navigation Links
Interview questions on Design Patterns in .NET
ASP.NET Ajax Interview Questions
Interview questions related to security
C# Interview Questions
ASP.NET Interview Questions
Interview Questions in ASP.NET 2.0
Articles at dotnetuncle.com
Skip Navigation Links
OOPs questions in .NET
Questions on .NET Framework
ADO.NET Interview Questions
Short Answer questions in .NET
Frequently asked differences in .NET
Important commonly used Acronyms in .NET
MS SQL, Oracle SQL Interview Questions



    
Dotnetuncle's Tip:

  C# Programming Language is said to have a fundamental type system, referred to as Unified Type System. This essentially implies that all types have a common ancestor type which is referred to as the common base type.