DML commands
SUDI
S – Select (To retrieve data)U – Update (to update data)
D – Delete(to delete rows of data)
I – Insert (to insert new row of data)
DDL commands
DRCAT
D – Drop (To delete a database or table)
R – Rename (To change the column name)
C – Create (To create a database or table)
A – Alter (To work on columns)
T – Truncate(To clear entire table data)
Alter contains three commands:
Alter Add (To add column)
Alter alter (To modify data type of column)
Alter drop (To delete a column)
Introduction to SQL
SQL is a language used to interact with the database.
SQL stands for Structured Query Language
SQL lets you access and manipulate databases
SQL is an ANSI (American National Standards Institute) standard.
SQL is not case sensitive.
RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL and Microsoft Access.
In RDMS data is stored in the form of tales which contains rows and columns.
SQL is divided into 4 Sub languages as follows:
DDL (Data Definition Language)
DML (Data Manipulation Language)
TCL (Transaction Control Language)
DCL (Data Control Language)
SQL stands for Structured Query Language
SQL lets you access and manipulate databases
SQL is an ANSI (American National Standards Institute) standard.
SQL is not case sensitive.
RDBMS
RDBMS stands for Relational Database Management System.RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL and Microsoft Access.
In RDMS data is stored in the form of tales which contains rows and columns.
SQL is divided into 4 Sub languages as follows:
DDL (Data Definition Language)
DML (Data Manipulation Language)
TCL (Transaction Control Language)
DCL (Data Control Language)
Windows Forms User Controls
User Controls are controls that are created by the users with customized requirements. We can create a new control with so that we can reuse it in our project.
Implementing User Controls
Select project template as Windows Form control Library
Click on OK
Drag and drop exiting controls in toolbox and edit it based on your requirements
Build the project to get the dll for usercontrol in project location
Example: Projects\MyUserControl\MyUserControl\bin\Debug
Goto toolbox and create a new tab with a right click on exiting tab of toolbox and select Add new tab
Edit the caption of tab
Right click on the new tab and click on choose items
Select the browse button and select the user control dll
New control will be added to the toolbox which can be used everywhere in the project by simple drag and drop option to the design of the form.
Implementing User Controls
Steps to create user control
File – New Project – Select language as C#Select project template as Windows Form control Library
Click on OK
Drag and drop exiting controls in toolbox and edit it based on your requirements
Build the project to get the dll for usercontrol in project location
Example: Projects\MyUserControl\MyUserControl\bin\Debug
Using User Controls
Create a new windows applicationGoto toolbox and create a new tab with a right click on exiting tab of toolbox and select Add new tab
Edit the caption of tab
Right click on the new tab and click on choose items
Select the browse button and select the user control dll
New control will be added to the toolbox which can be used everywhere in the project by simple drag and drop option to the design of the form.
StringBuilder and string
StringBuilder is mutable which means we can append, insert or replace text in string without creating new memory for it everytime. Once a StringBuilder is created text can be added to the existing text without creating new memory everytime whenever we are adding content to it. String Builder is under System.Text namespace. Append method is used to add text to the existing StringBuilder. Performance of StringBuilder is higher than string.
Output:
Hello world Second Line
Hello India Second Line for string
String
String is immutable which means once we create string object we cannot modify. Every time when you change the text using insert, replace or append methods new instance is created to hold the new value by discarding the old value. Performance of string is less than StringBuilder. String is under System namespace.
Example
program to use StringBuilder and string
using System;
using System.Text;
namespace Overriding
{
class Program
{
static void Main(string[] args)
{
// Create StringBuilder.
StringBuilder stringbuilder = new StringBuilder();
//Appending first line
stringbuilder.Append("Hello world ");
//Appending second line
stringbuilder.Append("Second Line");
//Printing text in StringBuilder
Console.WriteLine(stringbuilder);
//create string
string s;
//assign text to string
s = "Hello India ";
//append text to string
s +=
"Second Line
for string";
Console.WriteLine(s);
Console.ReadKey();
}
}
}
Output:
Hello world Second Line
Hello India Second Line for string
Dialogs
Dialogs will allow the user give their inputs.
ColorDialog
Allows the user to select a color from the system colors.
FolderBrowserDialog
Allows the user to select a folder his system.
FontDialog
Allows the user to select the font style available in the system.
OpenFileDialog
Allows the user to select a file from the system.
SaveFileDialog
Allows the user to select a location where he can save a file.
Example code to use all the dialogs
Drag and drop five button to the form and also all the five dialog controls to the form which are displayed on the bottom panel.
Change the text of the buttons to Color, Folder, Font, Open File and Save File and Names to BtnColor, BtnFolder, BtnFont, BtnOpenFile, BtnSaveFile.
Double click on each button to create the events and write the below code in them
ColorDialog
Allows the user to select a color from the system colors.
FolderBrowserDialog
Allows the user to select a folder his system.
FontDialog
Allows the user to select the font style available in the system.
OpenFileDialog
Allows the user to select a file from the system.
SaveFileDialog
Allows the user to select a location where he can save a file.
Example code to use all the dialogs
Drag and drop five button to the form and also all the five dialog controls to the form which are displayed on the bottom panel.
Change the text of the buttons to Color, Folder, Font, Open File and Save File and Names to BtnColor, BtnFolder, BtnFont, BtnOpenFile, BtnSaveFile.
Double click on each button to create the events and write the below code in them
private void BtnColor_Click(object sender, EventArgs e)
{
colorDialog1.ShowDialog();
BtnColor.BackColor = colorDialog1.Color;
}
private void BtnFolder_Click(object sender, EventArgs e)
{
folderBrowserDialog1.ShowDialog();
BtnFolder.Text = folderBrowserDialog1.SelectedPath;
}
private void BtnFont_Click(object sender, EventArgs e)
{
fontDialog1.ShowDialog();
BtnFont.Font = fontDialog1.Font;
}
private void BtnOpenFile_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
BtnOpenFile.Text = openFileDialog1.FileName;
}
private void BtnSaveFile_Click(object sender, EventArgs e)
{
saveFileDialog1.ShowDialog();
}
StatusStrip
StatusStrip is a collection of controls which are displayed at the bottom of the form which is generally used to display the status of the window form.
Default Event: Click which is fired when user click on the item.
Steps to create StatusStrip
Drag and drop a StatusStrip control to the form which is displayed on the bottom panel of the form but also shows up the dropdown with list of controls at the bottom of the form.
You can use the dropdown available at the bottom of the form to select and add controls in the StatusStrip which is present at the bottom of the form.
Double click on the StatusStrip item to see the generated event handler of that specific item and you can create event handler for each item to write some code that has to be executed when you click on that item in the runtime.
Default Event: Click which is fired when user click on the item.
Steps to create StatusStrip
Drag and drop a StatusStrip control to the form which is displayed on the bottom panel of the form but also shows up the dropdown with list of controls at the bottom of the form.
You can use the dropdown available at the bottom of the form to select and add controls in the StatusStrip which is present at the bottom of the form.
Double click on the StatusStrip item to see the generated event handler of that specific item and you can create event handler for each item to write some code that has to be executed when you click on that item in the runtime.
Example
code to display number of characters present in a textbox in status label
Double click on the textbox and write the
below code.
private void textBox2_TextChanged(object sender, EventArgs e)
{
toolStripStatusLabel1.Text = textBox2.Text.Length.ToString();
}