“Dasturlash texnologiyalari” fanidan


DDL (Data Definition Language)



Download 460,43 Kb.
bet6/8
Sana23.09.2022
Hajmi460,43 Kb.
#849996
1   2   3   4   5   6   7   8
Bog'liq
SQLDataReader bilan ma’lumotlarni oqish yozish

 

DDL (Data Definition Language)

DDL (Data Definition Language)

Create operatori yordamida jadval yaratish


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.

Satr ulanishlar

1. SQL Server Authentication uchun

string connectionString = @"Data Source =.\SQLEXPRESS; Initial Catalog = baza_nomi; User Id = sa; Password = parol";

2. Windows Authentication uchun

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();


Download 460,43 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish