Articles of level

There are many types of collections in the .Net Framework. The most general types of them are under the "System.Collections" namespace. All of them have the following basic methods and properties to manipulate the stored data.-

The SqlCommand class is -

  • To execute a SQL statement against a SQL Server database, you create a SqlCommand object that contains the statement. The Connection property of this class associates the command with a SqlConnection object, and the CommandText property contains the SQL statement to be executed.
  • The CommandType property indicates how the command object should interpret the value of the CommandText property. Instead of specifying a SQL statement for the CommandText property, for example, you can specify the name of a stored procedure, which consists of one or more SQL statements that have been compiled and stored with the database.
  • You can execute a command object directly by using one of the three Execute methods show. If, for example, you use ExecuteReader for a Select statement, the results are returned as a DataReader object. If you use ExecuteScalar, only the value in the first column and row of the query results is returned.
  • If the command contains an Insert, Update, or Delete statement, you will use the ExecuteNonQuery method to execute it. This method returns an integer value that indicates the number of rows that were affected by the command. If, for example, the command deletes a single row, the ExecuteNonQuery method returns 1.

The SqlDataReader class
This class is used to create a data reader object, which provides an efficient way to read the rows in a result set returned by a database query. In fact, when you use a data adapter to retrieve data, the data adapter uses a data reader to read through the rows in the result set and store them in a dataset.

  • A SqlConnection object is required to establish a connection to a SQL Server database.
  • A SqlCommand object is used to execute a SQL command against a SQL Server database.
  • A SqlParameter object is used to pass variable information to a SQL command.

The SqlParameter class lets you pass parameter values to a SQL command. Parameters arc commonly used to limit the number of rows retrieved by a Select statement. For example, you can retrieve the Product row for a specific product by passing the ProductlD as a parameter. Or, you can retrieve all of the products for a given category by passing the CategorylD as a parameter. Parameters are also commonly used to pass column values to Insert, Update, and Delete statements.

Aspx code generated for a basic SqlDataSource control
<asp:SqlDataSource ID="SqlDataSourcel" runat="server" ConnectionString="<%$ConnectionStrings:w3aspConnectionString%>"
SelectCommand="SELECT [CategoryID], [LongName] FROM [Categories]
ORDER BY [LongName]">

A date and time format string defines the text representation of a DateTime value that results from a formatting operation. In C# by calling any of the overloads of the DateTime constructor that allow you to specify specific elements of the date and time value like year , month or day.
  DateTime newDate = new DateTime(2015, 5, 1);
Here newDate represents year as 2015 and month as May and date as 1 .

Anonymous methods provide a technique to pass a code block as a delegate parameter. Anonymous methods are the methods without a name, just the body.
You need not specify the return type in an anonymous method; it is inferred from the return statement inside the method body.

Class declarations can have up to four different parts, surrounding the class keyword:

  • Attributes, 
  • Class-modifiers, 
  • Class-base, 
  • Class-body
The class-body element specifies type members. The following is an example of a class declaration:
public class Shape {
// class-body

Attributes can be posted at the front of a class declaration. These comprise user-defined metadata about the class; information which can be brought out at runtime.

Try Catch Finally is the basic building block of exception handling in c#. "Try" block keeps the code which may raise exception at runtime. The "catch" block handle the exception if try block gets error and "finally" block executes always whether exception is raised or not. A try block may have multiple catch blocks.

A Multiple Document Interface (MDI) programs can display multiple child windows inside them. This is in contrast to single document interface (SDI) applications, which can manipulate only one document at a time. Visual Studio Environment is an example of Multiple Document Interface (MDI) and notepad is an example of an SDI application. MDI applications often have a Window menu item with submenus for switching between windows or documents.

PreviousDisplaying 5 of 6Next
1 2 3 4 5 6
Need Help? Contact Us.

Log in


Forgot password?


New User