|
INTERVIEW QUESTIONS
MICROSOFT
ADO.NET
DETAILS
Question: How do I call a stored procedure from my application using ADO.Net?
Answer: Using stored procedures with ADO.Net in C# is extremely simple, especially when we have developed the application with SQL commands. All we need is:
* Create a command object (SqlCommand, etc) and specify the stored procedure name * Set the CommandType property of the command object to the CommandType.StoredProcedure enumeration value. This tells the runtime that the command used here is a stored procedure.
That’s it! The sample code to use with data adapter is:
C# Version
// Preparing Insert SQL Command SqlCommand insertCommand = new SqlCommand("InsertProc", conn); insertCommand.CommandType = CommandType.StoredProcedure; dataAdapter.InsertCommand = insertCommand; insertCommand.UpdatedRowSource = UpdateRowSource.None; ...
VB.Net Version
' Preparing Insert SQL Command Dim insertCommand = New SqlCommand("InsertProc", conn) insertCommand.CommandType = CommandType.StoredProcedure dataAdapter.InsertCommand = insertCommand insertCommand.UpdatedRowSource = UpdateRowSource.None
|
|
|
Category |
ADO.NET Interview Questions & Answers -
Exam Mode /
Learning Mode
|
Rating |
(0.2) By 9118 users |
Added on |
8/31/2014 |
Views |
68246 |
Rate it! |
|
|
Question:
How do I call a stored procedure from my application using ADO.Net?
Answer:
Using stored procedures with ADO.Net in C# is extremely simple, especially when we have developed the application with SQL commands. All we need is:
* Create a command object (SqlCommand, etc) and specify the stored procedure name * Set the CommandType property of the command object to the CommandType.StoredProcedure enumeration value. This tells the runtime that the command used here is a stored procedure.
That’s it! The sample code to use with data adapter is:
C# Version
// Preparing Insert SQL Command SqlCommand insertCommand = new SqlCommand("InsertProc", conn); insertCommand.CommandType = CommandType.StoredProcedure; dataAdapter.InsertCommand = insertCommand; insertCommand.UpdatedRowSource = UpdateRowSource.None; ...
VB.Net Version
' Preparing Insert SQL Command Dim insertCommand = New SqlCommand("InsertProc", conn) insertCommand.CommandType = CommandType.StoredProcedure dataAdapter.InsertCommand = insertCommand insertCommand.UpdatedRowSource = UpdateRowSource.None Source: CoolInterview.com
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|
|
Related Questions |
View Answer |
|
How do stored procedure look like, can you provide some sample stored procedures?
|
View Answer
|
|
What is the advantage of using stored procedure over the SQL queries?
|
View Answer
|
|
What is a stored procedure?
|
View Answer
|
|
How do I write common code for different dot net framework data providers?
|
View Answer
|
|
How do I insert records using data reader?
|
View Answer
|
|
How do I read data (or records) from database using data reader?
|
View Answer
|
|
What is the architecture of connected environment of data access in ADO.Net?
|
View Answer
|
|
How do I update a record in the table using ADO.Net dataset?
|
View Answer
|
|
How do I save the changes, made in the dataset, to the database?
|
View Answer
|
|
How do I read records from the data tables?
|
View Answer
|
|
How do I define a data adapter?
|
View Answer
|
|
How do I create a command and supply the SQL query to ADO.Net? (Command object and command string)
|
View Answer
|
|
How do I find the connection string for the database server?
|
View Answer
|
|
What are the basic steps involved in data access with ADO.Net in disconnected environment?
|
View Answer
|
|
What is the Dot Net Framework data provider for OLEDB?
|
View Answer
|
|
What is the Dot Net Framework data provider for Oracle?
|
View Answer
|
|
What is the Dot Net Framework data provider for SQL Server?
|
View Answer
|
|
Why should one use a specialized data provider when the data can be accessed with general data providers?
|
View Answer
|
|
What are the standard dot net framework data providers that are shipped with the Dot Net Framework 1.1?
|
View Answer
|
|
What does it mean by Dot Net Framework Data Provider?
|
View Answer
|