資料庫求碼
use
資料庫名稱(db)
go
--讀者表
create
table
zhe
(
id
int
identity(1,1),
numid
varchar(20)
primary
key,
--主鍵
dname
varchar(20),
post
varchar(20),
dept
varchar(20)
)
--圖書表
create
table
books
(
id
int
identity(1,1)
primary
key,
bnum
varchar(20)
foreign
key
references
zhe(numid),
--外鍵
bname
varchar(20),
bauthor
varchar(20),
bpress
varchar(50),
bprice
decimal,
btype
varchar(10)
)
--借閱記錄
create
table
lendrecord
(
id
int
identity(1,1),
lbnum
varchar(20)
foreign
key
references
zhe(numid),
--外鍵
ldate
datetime,
yhdate
datetime,
redate
datetime
)
Ⅱ VB6.0編程,想把ACCESS07資料庫【ABC】中表1中的所有內容都復制到同一資料庫的表2裡面,求代碼。
在工程里引用microsoft activex data objects 2.7 library
Dim cn As New ADODB.Connection, rs1 As New ADODB.Recordset, sql As String '在通用聲明裡定義,其中cn是連接對象,rs1是記錄集,sql是查詢語句
Private Sub Form_Load()
cn.Open "provider=microsoft.jet.oledb.4.0;data source=" + App.Path + "\資料庫名.mdb" + ""
sql = "select * from 表名"
rs1.Open sql, cn
rs1.MoveFirst
Do While Not rs1.EOF
Combo1.AddItem rs1("欄位名")
rs1.MoveNext
Loop
rs1.Close
End Sub
如果你還有什麼不懂的,可以網路搜下:編程回憶錄,他們現在正在錄制這方面的教程,都是零基礎開始,由淺入深。
Ⅲ 資料庫,求代碼
1、 select student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
course.cname <> '信息系統'
2、 select c1.cno,c1.cname
from course c1,course c2
where c1.cno = c2.cpno and
c1.ccredit = c2.ccredit
3、 select student.sno,student.sname
from student
where not exists
(
select 1
from sc
where grade < 80 and
sc.sno = student.sno
)
4、 select c1.sno,c1.sname
from
(
select student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
course.cname = '資料庫'
)c1,
(
select student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
course.cname <> '操作系統'
)c2
where c1.sno = c2.sno
5、 select c1.avg,c1.sno,c1.sname
from
(
select avg(sc.grade) avg,student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno
group by student.sno,student.sname
)c1
(
select avg(sc.grade) avg
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
student.sname = '劉晨'
)c2
where c1.avg > c2.avg