Friday, 30 December 2011

What is difference between ExecuteReader, ExecuteNonQuery and ExecuteScalar.

ExecuteReader : Use for accessing data. It provides a forward-only, read-only, connected recordset. ExecuteNonQuery : Use for data manipulation, such as Insert, Update, Delete. ExecuteScalar : Use for retriving 1 row 1 col. value., i.e. Single value. eg: for retriving aggregate function. It is faster than other ways of retriving a single value from D...

Concept of Interface

What is Interface? An Interface is a group of constants and method declaration. .Net supports multiple inheritance through Interface. Interface states “what” to do, rather than “how” to do. An interface defines only the members that will be made available by an implementing object. The definition of the interface states nothing about the implementation of the members, only the parameters they take and the types of values they will return. Implementation of an interface is left entirely to the implementing class. It is possible, therefore,...

OOPs Interview Questions

OOPs FAQs : Object Oriented Interview Questions ClassA user-defined data structure that groups properties and methods. Class doesn’t occupies memory. ObjectInstance of Class is called object. An object is created in memory using keyword “new”. Difference between Struct and Class Struct are Value type and are stored on stack, while Class are Reference type and are stored on heap. Struct “do not support” inheritance, while class supports inheritance. However struct can implements interface. Struct should be used when you...

Monday, 5 December 2011

How to: Bind a ComboBox or ListBox Control to Data

Set the DataSource property to a data source object. Possible data sources include a BindingSource bound to data, a data table, an array, a data view, a dataset, a data view manager, or any class that implements the IList interface. If you are binding to a table, set the DisplayMember property to the name of a column in the data source. - or - If you are binding to an List, set the display member to a public property of the type in the list. C#  private...

Saturday, 3 December 2011

How to Create Crystal Reports in .NET

Open --> Visual Studio .NET.select a new Visual Basic .NET Project. From main menu in Visual Studio select PROJECT-->Add New Item . Then Add New Item dialogue will appear and select Crystal Reports from the dialogue box. Select Report type from Crystal Reports gallery.  click OK.Then select the appropriate connection to your database. Here we are going to select OLEDB connection for SQL...

How to Binding Text Boxes to Data source in C#/VB.NET

How to bind textboxes to data source using Visual Studio Select TextBox & from the properties window select (Advanced) from DataBindings From the list of sources select ‘Add Data Source’ Select Appropriate Data Source When prompted to Save the connection string accept it  The dialog will get the list of data sources. From the list select the table you want and the columns Assign the column to the particular text box//---------------------------------------------------------------------------------------------------- ...

Friday, 2 December 2011

How to Bind a Lisbox to Database in C# (.NET)

Bind Listbox to Dataset using Visual Studio Following steps would help you in connected a database/dataset to the list box Step1: Add a List Box control to the form and select the DataSource from quick edit Step 2: Select appropriate data source type (We are going to connect to an SQL Server DB) Step 3: Select Appropriate Database Model Step 4: Add a connection to database and select appropriate DB Step 5: Select appropriate field you...

How to send mail using Gmail in C#

How to send mail using .NET Here is a simple code that sends mail from gmail account I have used this code to get the details from contact page to my mail ID The code uses System.Net Mail namespace protected void btnSubmit_Click(object sender, EventArgs e)  {       try     {         string sFrom = "telanganadeccan@gmail.com";         string sTo = "info@rowsandcolumns.in";         string sMessage = txtComments.Text + "\n" + txtName.Text;         string sSubject = txtName.Text;         string sMail = txtEmail.Text;          MailAddress oMailfrom = new MailAddress(sFrom);         MailAddress oMailTo = new MailAddress( sTo);         MailMessage message = new MailMessage(oMailfrom, oMailTo );         message.Body = "From " + sSubject + "\n Mail ID " + sMail + "\n Comments :\n" + sMessage;         SmtpClient client = new SmtpClient();         client.Timeout = 20000;         message.Subject = sSubject;         client.EnableSsl = true;         client.Send(message );                  Response.Redirect ("~/Thanks.aspx");     }     catch (Exception ex)     {         Response.Redirect("~/Thanks.aspx");     } } ...

Thursday, 1 December 2011

How to use Treeview designer in C# Application

C# Treeview designer example Treeview control gives a nice hierarchical view for the users of a given concept. The following example shows how to create a simple tree-view control using the designer Add a Tree View Control to the form Select the TreeView Tasks from the controlAdd the root item – XYZ Automobiles Click the root item and then click on the Add...