2,此时表名自定义为查询1,右击左上角的表名,选择SQL。
3,输入SQL语言:ALTER TABLE 表名 ADD 要添加的记录字段名;
4,点击保存,在保存为里更改表名,也可以不更改,点击运行,再打开要添加记录的表,就可以看到添加了记录了。
Adodc1.Recordset.AddNewAdodc1.Recordset.Fields("用户姓名")
=
Text1.Text
Adodc1.Recordset.Fields("用户密码")
=
Text2.Text
Adodc1.Recordset.Fields("用户权限")
=
1
Adodc1.Recordset.Update
Adodc1是控件的名称,这个不用说了。并且对Adodc1控件做好了如连接字符串之类的设置,在控件的属性里可以设置。
第一句向记录集添加新项
后面几句向相应字段写入数据
最后一句更新记录集
“修改”按钮的程序 \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 Sub欢迎分享,转载请注明来源:内存溢出
评论列表(0条)