“修改”按钮的程序 \x0d\x0aPrivate Sub cmdEdit_Click() \x0d\x0asql = "select * from 停时统计 where date = cdate('" &Text8.Text &"') and ycqk = '" &Combo1.Text &"'and id = '" &DataGrid1.Columns(2).CellText(DataGrid1.Bookmark) &"'" \x0d\x0ars.Open sql, dm, adOpenDynamic, adLockOptimistic \x0d\x0ars.Fields("id") = Text7.Text \x0d\x0ars.Fields("ycqk") = Combo1.Text \x0d\x0ars.Fields("date1") = Text1.Text \x0d\x0ars.Fields("time1") = Text2.Text \x0d\x0ars.Fields("date2") = Text3.Text \x0d\x0ars.Fields("time2") = Text4.Text \x0d\x0ars.Update \x0d\x0ars.Close \x0d\x0aEnd Sub \x0d\x0a\x0d\x0a'“删除”按钮的程序 \x0d\x0aPrivate Sub cmdDelete_Click() \x0d\x0astrFCode = DataGrid1.Columns(0).CellText(DataGrid1.Bookmark) \x0d\x0astrSCode = DataGrid1.Columns(2).CellText(DataGrid1.Bookmark) \x0d\x0astrCCode = DataGrid1.Columns(1).CellText(DataGrid1.Bookmark) \x0d\x0asql = "select * from 停时统计 where date='" &strFCode &"' and id='" &strSCode &"' and ycqk='" &strCCode &"'" \x0d\x0ars.Open sql, dm, adOpenDynamic, adLockOptimistic \x0d\x0ars.Delete \x0d\x0ars.Update \x0d\x0ars.Close \x0d\x0aEnd Sub \x0d\x0a\x0d\x0a'“增加”按钮的程序 \x0d\x0aPrivate Sub Command1_Click() \x0d\x0asql = "select * from 停时统计 order by id" \x0d\x0ars.Open sql, dm, adOpenDynamic, adLockOptimistic \x0d\x0ars.AddNew \x0d\x0ars.Fields("date") = Date \x0d\x0ars.Fields("id") = Text7.Text - 1 \x0d\x0ars.Fields("ycqk") = Combo1.Text \x0d\x0ars.Fields("date1") = Text1.Text \x0d\x0ars.Fields("time1") = Text2.Text \x0d\x0ars.Fields("date2") = Text3.Text \x0d\x0ars.Fields("time2") = Text4.Text \x0d\x0ars.Update \x0d\x0ars.Close \x0d\x0a\x0d\x0aWith Adodc1 \x0d\x0aAdodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &App.Path &"\db1.mdbPersist Security Info=False" \x0d\x0aAdodc1.RecordSource = "select * from 停时统计 where date = cdate('" &Text8.Text &"') and ycqk = '" &Combo1.Text &"' order by id" \x0d\x0aAdodc1.Refresh \x0d\x0aDataGrid1.Refresh \x0d\x0aEnd With \x0d\x0aEnd Subdim SqlStr as String
sqlstr="delete * from tbluser where username='" &text1.text &"'"
然后执行这个sql语句(sqlstr)就行了
查询Sql=“select
*
from
数据表
where
字段名=字段值
order
by
字段名[desc]”
Sql=“select
*
from
数据表
where
字段名
like
‘%字段值%’
order
by
字段名[desc]”
Sql=“select
top
10
*
from
数据表
where
字段名
order
by
字段名[desc]”
Sql=“select
*
from
数据表
where
字段名
in
(‘值1’,‘值2’,‘值3’)”
Sql=“select
*
from
数据表
where
字段名
between值1
and
值2
可以利用DELETE语句,将表格中的记录删除
Sql=“delete
from
数据表
where
条件表达式”
DELETE语句
Sql=“delete
from
数据表”(将数据表所有记录删除)
例:将职员表格中姓名叫做‘李’的记录删除
DELETE * FROM 职员表格
WHERE 姓名='李'
更新数据记录
Sql=“update
数据表
set
字段名=字段值
where
条件表达式”
Sql=“update
数据表
set
字段1=值1,字段2=值2……字段n=值n
where
条件表达式”
添加数据记录
Sql=“insert
into
数据表
(字段1,字段2….)
values(值1,值2….)”
Sql=“insert
into
目标数据表
select
*
from
源数据表”(把源数据表的记录添加到目标数据表)
INSERT INTO语句
新建一条数据到表格当中
例:从训练人员表中,将职员雇用时间超过30天者,加入到正式职员表中。
INSERT INTO 职员表
SELECT 训练人员表.*
FROM 训练人员表
WHERE 雇用天数>30;
评论列表(0条)