Windows Application - SPLessons

Win App Basic SQL Operations

Home > Lesson > Chapter 20
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Win App Basic SQL Operations

Windows Application Basic SQL Operations

What is SQL?

shape Description

SQL means "Structured Query Language". SQL is used like a language which is used to communicate with the database. Here, database means SQL SERVER.

SQL uses

shape Description

To connect with the backend and get the database from the SQL Server into the front end application, one have to use the SQL. SQL is a Query language which have the queries.

What is a Query?

shape Description

Query means a question which one want to ask database. There are two types of queries. Action Query
  • Action Query is used to perform some operations like insert, delete, and update.
Select Query
  • Select Query is only used to retrieve data from the database.
Before using SQL in Front end, one have to know about the basic operations like creating, inserting, deleting, and selecting. Etc.

Creating a table

shape Programming Tips

To create a table in SQL, use the below syntax.

shape Syntax

create table table_name(column_name1 datatype, column_name2 datatype....Column_nameN datatype);

shape Example

create table tbl_emp(Id int, Name varchar(20),Salary int); Inserting rows into a table.

shape Syntax

insert into table_name values('value1','value2'.....valueN);

shape Example

insert into tbl_emp values(1,'John','50000');

How to write the query in C#

shape Programming Tips

Let's take an example. Suppose one want to insert a Textbox value in a table. Then write the query as insert into tbl_emp values('"+txtName.Text+"');

Updating rows in the table

shape Programming Tips

Syntax to update the rows in a table in SQL

shape Syntax

update table table_name set column_name=value where column_name=value

shape Example

Suppose one want to update above inserted name(John) as David Then, update table tbl_emp set name='David' where Id=1

How to write the query in C#

shape Description

Updation in C# is same as above mentioned query. But syntax is changed. update table tbl_emp set name='"+txtName.Text+"' where Id='"+txtId.Text+"'

Selecting set of rows from table

shape Programming Tips

To select the rows from table use the below syntax.

shape Syntax

select * from table_name; OR select column_name1, column name2..etc from table_name;

shape Example

select * from tbl_emp;

How to write the query in C#

shape Programming Tips

select command is similar as in SQL. select * from tbl_emp;