Program Example:
|
Connecting Database sharp1.cs class xyz1 { public static void main() { try { System.Data.ADO.ADOConnection s; S=new System.Data.ADO.ADOConnection(); System.Console.Writeline("C-Sharp); } catch(System.Exception e) { System.console.Writeline(e.ToString()); }}} |
Above program can be compiled through command line at DOS promot giving command line option as /r:System.Data.Dll
Because the code for ADO.Connection is available at this DLL. The above program consists of an object s resembling as System.ado.adoconnection .
Thus we are creating the object s by the statement:
System.Data.ADO.ADOConnection s;
From the output it is clear that the constructor has thrown no exception, as otherwise catch block would have been executed.