1. If given the following delegate declaration: publicdelegate void TestCallback(object obj); write code segments to perform the following: A) Design a non-static method that can be contained within an instance/object of the TestCallback delegate type. This method should display values of two data fields contained within the object that is passed to the method. Make-up your own method definition that meets these requirements. B) Create an instance of the TestCallbackdelegate (i.e. a delegate object) and initialize this object to contain an entry point of the method defined in part A) as well as a copy of the object that calls this method. C) Create an event field and the corresponding event property of the given TestCallback delegate type. D) Write a complete statement that will add the method that you created in question A) to be a handler of the event you created in question C). Make up your own object name that raises the event. ANSWER: A) B) C) D) 2. Write an SQL statement/command that will select all records from two tables named Cars and Services(i.e., joined tables), if the primary key is carID from the Carstable and the foreign key is carID from the Services table.These records will be sorted by the Date field from the Servicestable in the ascending order. ANSWER: 3. Fill in the missing code segments. Please read comments. OleDbDataAdapter dtad = new OleDbDataAdapter(); string constr = "Provider=Microsoft.ACE.OLEDB.12.0;"+ "Data Source=Database1.accdb"; OleDbConnection conobj = new OleDbConnection(___________________); conobj.Open(); //Updates in the Parts table the value of the Quantity field by //assigning a value stored within the variable qval for the part //where Description field value is entered into the text box named //txtDescription. string sqlUpdate="_________________________________________ __________________________________________________________ __________________________________________________________"; dtad.UpdateCommand = new OleDbCommand(______________________); _______________________________________; //executes update command conobj.Close(); 4. If it is assumed that a text file named parts.txt has been created and it contains many records/lines that consists of a part description and a part quantity separated by a comma as shown in the following record/line example: USB32,150 Write a code to execute the following tasks: A) Open this file for reading and read/copy all file records into an array. Include all necessary declarations and error checking/handling when opening file. B) Search for a part description in this array and display its quantity in a message box. Please note that the part description to search for is entered by the user into the txtPart text box. ANSWER: A) B)
1. If given the following delegate declaration:
publicdelegate void TestCallback(object obj);
write code segments to perform the following:
TestCallback delegate type.
ANSWER:
A)
B)
C)
D)
2. Write an SQL statement/command that will select all records from two tables named Cars and Services(i.e., joined tables), if the primary key is carID from the Carstable and the foreign key is carID from the Services table.These records will be sorted by the Date field from the Servicestable in the ascending order.
ANSWER:
3. Fill in the missing code segments. Please read comments.
OleDbDataAdapter dtad = new OleDbDataAdapter();
string constr = "Provider=Microsoft.ACE.OLEDB.12.0;"+
"Data Source=Database1.accdb";
OleDbConnection conobj = new OleDbConnection(___________________);
conobj.Open();
//Updates in the Parts table the value of the Quantity field by
//assigning a value stored within the variable qval for the part
//where Description field value is entered into the text box named
//txtDescription.
string sqlUpdate="_________________________________________
__________________________________________________________
__________________________________________________________";
dtad.UpdateCommand = new OleDbCommand(______________________);
_______________________________________; //executes update command
conobj.Close();
4. If it is assumed that a text file named parts.txt has been created and it contains many records/lines that consists of a part description and a part quantity separated by a comma as shown in the following record/line example: USB32,150
Write a code to execute the following tasks:
ANSWER:
A)
B)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps