Академический Документы
Профессиональный Документы
Культура Документы
Reg.No.7050070056
1. List out the core namespaces of the object used to bridge applications and databases.
Ans.
ADO.NET is a set of computer software components that programmers can use to access
data and data services.
Several important namespaces make up the ADO.NET data access technology. First, the
.NET Data Providers is implemented in the System. Data.SqlClient,
System.Data.OracleClient, System.Data.OleDbClient, and System.Data.Odbc namespaces.
The classes in these four namespaces provide the underlying database connectivity that’s
required by all of the other ADO.NET objects.
1. The System.Data.SqlClient namespace provides connectivity to SQL Server 7, SQL
Server 2000, and SQL Server 2005 databases.
2. The System.Data. OracleClient namespace provides connectivity to Oracle 8 and 9
databases.
3. The System.Data.OleDbClient namespace provides connectivity to SQL Server 6.5
and earlier databases, as well as Access and Oracle databases.
4. And the System.Data. Odbc namespace provides connectivity to legacy databases
using ODBC drivers.
namespace CrtDataSet
{
class Program
{
static void Main(string[] args)
{
//-- Instantiate the data set and table
DataSet SongDS = new DataSet();
DataTable songTable = SongDS.Tables.Add();
//-- Cycle thru the data table printing the values to the screen
foreach (DataTable table in SongDS.Tables)
{
foreach (DataRow row in table.Rows)
{
Console.WriteLine(row["Band"] + " ~ " + row["Song"]);
}
}
}
}
}
Ans
01.using System;
02.using System.Runtime.InteropServices;
03.namespace ANamespace
04.{
05.
06. public interface ASignatures
07. {
08. string FName();
09. string SName();
10. int Age { get;}
11. }
12.
13. [ClassInterface(ClassInterfaceType.AutoDual)]
14. public class AClass :ASignatures
15. {
16. public string FName()
17. {
18. return "Imran";
19. }
20. public string SName()
21. {
22. return "Nathani";
23. }
24. public int Age
25. {
26. get { return 24; }
27. }
28. }
29.}
We can then access our newly created ActiveX control via JavaScript. We will simply display
the data returned by the methods and property in alert boxes. The below code demonstrates how
we can access the properties in the ActiveX control.
01.<html>
02.<head>
03. <script language="javascript">
04. <!-- Load the ActiveX object -->
05. var x = new ActiveXObject("ANamespace.AClass");
06.
07. <!-- Access the Method -->
08. alert(x.FName());
09. alert(x.SName());
11. <!-- Access the Property -->
12. alert(x.Age);
13. </script>
14.</head>
15.<body>
16.</body>
17.</html>
Part-B
4. Explain the hierarchy of windows forms components with necessary figure. Write the
programmatic steps to create the sample windows form application.
Ans. The following illustration shows the hierarchy of components and controls in the
System.Windows.Forms namespace:
first open Visual Studio and choose New Project. In the New Project window, create a new C#
Windows application, and name it ProgCSharpWindowsForm, as shown in Figure 13-2.
You can use the Properties window to set the static properties of the various controls. For
example, to add text to label1, you can type the words "Hello World" into the box to the right
of its Text property. If you want to change the font for the lettering in the HelloWorld label,
click the Font property shown in the lower-right corner of Figure 13-5. (You can provide text in
the same way for your buttonbutton1by selecting it in the Property window and typing the word
"Cancel" into its Text property.)
Once you have the form laid out the way you want, all that remains is to create an event handler
for the Cancel button. Double-clicking the Cancel button will create the event handler, register it,
and put you on the code-behind page (the page that holds the source code for this form), in which
you can enter the event-handling logic, as shown in Figure 13-6.
Application.Exit( );
Visual Studio .NET generates all the code necessary to create and initialize the components. The
complete source code is shown in Example 13-2, including the one line of code you provided
(shown in bold in this example) to handle the Cancel button-click event.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ProgCSharpWindowsForm
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblOutput;
private System.Windows.Forms.Button btnCancel;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1( )
{
//
// Required for Windows Form Designer support
//
InitializeComponent( );
//
// TODO: Add any constructor code
// after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose( );
}
}
base.Dispose( disposing );
}
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main( )
{
Application.Run(new Form1( ));
}
5. Create a Windows Form application that shows the coordinates of mouse pointer on the
tail of mouse pointer. Coordinate change must be effected. Eg:
Ans x,y
For this purpose, Control.MousePosition Property is used.
The MousePosition property returns a Point that represents the mouse cursor position at the time
the property was referenced. The coordinates indicate the position on the screen, not relative to
the control, and are returned regardless of whether the cursor is positioned over the control. The
coordinates of the upper-left corner of the screen are 0,0.
6. Write a code to develop a notepad with a button on toolbar that speak out the text.
Ans.
Add Speech Object Library reference to your Application using right click on Project & click on
Add Reference.
2). After Adding Referece of Speech Object Library Drag one textbox control on your WinForm
& give the name txttexttospeech.
3). After that put this belowed code on your page load event of the form.