Page 99 - DCAP312_WEB_TECHNOLOGIES_II
P. 99
Unit 5: Database Access
• Replace values with placeholders (for example, “@emp_id” or “@fname”) so that your Notes
command text uses parameters. See the DELETE statement before these steps for an
example.
• Create your OleDbCommand or SqlCommand object, and pass in the connection object
that you created in the first step and the command text that contains the parameter
placeholders.
For each parameter, add a parameter object to the command object’s parameters collection. For
each parameter, you must specify a name and data type.
objCmd.Parameters.Add( “@emp_id”, SqlDbType.Char, 9);
Stored procedures can have parameters that return values and output parameters. You must
also set a value for each input parameter before you can run the query:
objCmd.Parameters[ “@emp_id”].Value = “MSD12923F”;
Run the query as follows:
try
{
objCmd.ExecuteNonQuery();
}
catch (System.Exception e)
{
Console.WriteLine(e.Message);
}
Console.WriteLine( “Record Deleted”);
Write a program to insert the data in the data base.
Self Assessment Questions
Multiple Choice Questions
1. Data Adapter to focus the ………………….on a specific member.
(a) execute Xml reader() (b) update operation
(c) server controls (d) validator control
2. Set of APIs was made to ………………………with data in the data store.
(a) connectivity (b) connection
(c) communicate effectively (d) linking and embedding
3. ………………is one that can be dispersed or replicated among different points in a network.
(a) A distributed database (b) Data binding
(c) ODBC stands (d) Embedding
4. ……………………………, as well as an object called a Data Reader.
(a) Database (b) Execute scalar()
(c) the ADO.NET (d) Command objects
LOVELY PROFESSIONAL UNIVERSITY 93