DDL (Data Definition Language) DDL (Data Definition Language)
create table talaba(
tr int not null primary key,
familiya varchar(25),
ism varchar(25));
create table talaba(
tr int not null,
familiya varchar(25),
ism varchar(25),
constraint tk primary key(tr)
);
create table talaba(
tr int not null,
familiya varchar(25),
ism varchar(25),
tr1 int,
constraint tk primary key(tr),
constraint fk foreign key(tr1)
references baho(tr) );
create table talaba(
tr int,
Ism varchar(25),
vaqt date);
1
2
3
4
DML (Data Manipulation Language) DML (Data Manipulation Language) Update operatori Insert operatori Delete operatori
update talaba
set ism='Nargiza'
where ism = 'Maftuna';
insert into talaba (tr, familiya, ism, tug_yili)
values (10,'Soliyeva','Gavharoy','11/18/1999');
delete talaba;
update talaba
set ism='Nargiza‘;
1
3
4
2
delete talaba
where ism = ‘Nargiza’;
5
DQL (Data Query Language) DQL (Data Query Language) Select operatori 4. Visual C# dasturda SQLDataReader bilan ishlash. 4. Visual C# dasturda SQLDataReader bilan ishlash. 1. SQL Server Authentication uchun string connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = baza_nomi; User Id = sa; Password = parol"; string connectionString = @"Data Source=.\SQLEXPRESS; Initial Catalog=baza_nomi; Integrated Security=True"; Jadvalga qiymat qo`shish SQLCommand orqali. Jadvalga qiymat qo`shish SQLCommand orqali. string connectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog =usersdb;Integrated Security=True"; using (SqlConnection connection = new SqlConnection(connectionString)) { string sqlExpression = "INSERT INTO talaba (t_r, familiya, ism, tug_yili) "+ " values (12,'O`rinova','Mahfuza', '07/13/1999');"; try { connection.Open(); Console.WriteLine("Bazaga ulandi"); SqlCommand command = new SqlCommand(sqlExpression, connection); int qiymat = command.ExecuteNonQuery(); Console.WriteLine("{0}: yozuv qo`shildi ", qiymat); } catch { connection.Close(); Console.WriteLine("Bazaga ulanishda xatolik mavjud!!!"); } Natija connection.Close(); Console.Read(); } Jadvalga konsol oyna orqali kiritish. Jadvalga konsol oyna orqali kiritish. using (SqlConnection connection = new SqlConnection(connectionString)) { string ism, familiya, tug_yili; int tr; Console.WriteLine("Tartib raqami:"); tr= int.Parse(Console.ReadLine()); Console.WriteLine("Familiya:"); familiya = Console.ReadLine(); Console.WriteLine("Ism:"); ism = Console.ReadLine(); Console.WriteLine("Tug`ilgan yili('oy/kun/yil'):"); tug_yili = Console.ReadLine();
Do'stlaringiz bilan baham: |