2023年計算機附屬 資料庫 c

2021-09-12 11:47:29 字數 4127 閱讀 9920

資料庫建立

create database test120171;

gouse test120171

gocreate table department(

deptno int primary key not null,

deptname varchar(20) not null)

gocreate table pgroup(

groupno int primary key,

groupname varchar(20) not null,

deptno int not null,

month int ,

number int not null check(number<80),

foreign key (deptno) references department(deptno))

create table patient(

pid int primary key,

pname varchar(20) not null,

pdate date not null,

groupno int,

foreign key (groupno) references pgroup(groupno))

insert into patient values('880101','李一','1980/6/1','11')

insert into patient values('880102','王二','1978/2/3','15')

insert into patient values('880103','張三','1969/11/2','13')

insert into patient values('880104','劉四','1975/7/20','13')

insert into patient values('880105','陳五','1986/5/16','14')

insert into patient values('880106','楊六','1998/4/23','13')

insert into patient values('880107','趙七','2000/3/1','12')

insert into patient values('880108','周八','1992/7/5','11')

insert into pgroup values('11','心內科','111','3','32')

insert into pgroup values('12','呼吸內科','111','4','45')

insert into pgroup values('13','中醫保健科','333','3','68')

insert into pgroup values('14','骨科','222','4','28')

insert into pgroup values('15','心外科','222','4','56')

insert into pgroup values('16','心內科','111','3','32')

insert into department values('111','內科')

insert into department values('222','外科')

insert into department values('333','中醫科')

goselect department.deptname,pgroup.groupname,patient.pname

from department,pgroup,patient

where department.deptno=pgroup.deptno and pgroup.groupno=patient.groupno

group by department.deptname,pgroup.groupname,patient.pname

order by department.deptname desc,pgroup.groupname asc,patient.pname desc

goselect department.deptname,sum(pgroup.number)人數

from department,pgroup

where department.deptno=pgroup.deptno

group by department.deptname

goselect pgroup.month,sum(number)當月人數

from pgroup

group by pgroup.month

goselect min(number)最少人數,max(number)最多人數

from pgroup

c#

dbhelpersql.cs

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

using system.data.sqlclient;

using system.data;

using system.windows.forms;

namespace test

else

}catch(exception ex)

}public static datatable tableselect(string sql,sqlparameter para = null)

catch(exception ex)}}

}

program.cs

using system;

using system.collections.generic;

using system.linq;

using system.threading.tasks;

using system.windows.forms;

namespace test

catch(exception ex)

dbhelpersql.conn.close();}}

}

多選框的應用

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.linq;

using system.text;

using system.threading.tasks;

using system.windows.forms;

using system.data.sqlclient;

namespace test

private void button1_click(object sender, eventargs e)

else

sql += string.format(" and department.deptname=''", textbox1.text);

}if (checkboxgroupname.checked)

else

sql += string.format(" and pgroup.groupname=''", textbox2.text);

}if (checkboxpname.checked)

else

sql += string.format(" and patient.pname=''", textbox3.text);

}sql+=string.format(@" group by department.deptname,pgroup.groupname,patient.pname

order by department.deptname desc, pgroup.groupname asc, patient.pname desc");

datagridview1.datasource = dbhelpersql.tableselect(sql);}}

}

2023年計算機考研程式設計

題目 請設計乙個演算法,將給定的表示式樹 二叉樹 轉換為等價的中綴表示式 通過括 號反映操作符的計算次序 並輸出。例如,當下列兩棵表示式樹作為演算法的輸入時 二叉樹結點定義如下 typedef struct node btree 要求 1 給出演算法的基本設計思想。2 根據設計思想,採用c或c 語言...

百度2023年計算機視覺筆試題

第一部分 有些題目不記得了 解析 首先this指標的作用 編譯器在識別類時,要經歷三個過程 1.識別類名 2.識別類中的成員變數 3.識別函式並對函式進行改寫 預設的為函式加上指標this 在類中呼叫函式就是要通過this指標來儲存這個類的位址,然後根據this指標提供的位址來對類成員變數進行操作。...

2023年計算機網路考研題

答案 假設osi參考模型的應用層欲傳送400 b的資料 無拆分 除物理層和應用層之外,其他各層在封裝pdu時均引入20 b的額外開銷,則應用層資料傳輸效率約為 a.80 b.83 c.87 d.91 34.若通道在無雜訊情況下的極限資料傳輸速率不小於訊雜比為30 db條件下的極限資料傳輸速率,則訊號...