此次项目仅仅是通过ACCESS一个工具实现,数据库设计和前台访问两个功能。主要是通过ACCESS的窗体设计来实现
其实ACCESS窗体内的代码和VB十分相似。这里说明下,便于回忆:
1. 数据文件和窗体设计不是同一个文件的情况:
Code 1Dim cnn As ADODB.Connection 2 Dim rs As ADODB.Recordset 3 4 Set cnn = New ADODB.Connection 5 Set rs = New ADODB.Recordset 6 7 cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Projects\Tec\test.mdb;Persist Security Info=False" 8' rs.CursorLocation = adUseClient 9 rs.Open "select * from UserInfo", cnn, adOpenDynamic, adLockPessimistic10
当然这里可以写的更好,比如说,数据文件地址是个可变参数,查询信息时增加用户名和密码
2. 数据文件和窗体设计在一个文件中:
Code 1Dim rs As New ADODB.Recordset2Dim str As String34Set rs = New ADODB.Recordset56str = "select * from admin where admin.sno='" & Me.username & "' and admin.password = '" & Me.password & "'"7rs.Open str, CurrentProject.Connection, adOpenKeyset, adLockOptimistic8