VB中如何向access数据库中添加记录并显示最新记录

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:58:11
一个数据库“bj”,表格“bjjl”,四个字段“竞标时间”“竞标价格”“竞标单位”“竞标标段”,希望“标段时间”自动生成,“标段单位”自动在登陆时提取用户名,“标段价格”和“标段标段”从“Text1”和“Text2”获得。
哪位大侠知道请指点小弟,如有视频教程为上(财富增加10分)。(在线期待中~~~~~~~~~)

给你代码参考:
竞标时间若要自动生成只要在Access设置就可以了。然后设置struser变数来储存用户名.

【登录代码】
Private Sub cmdlogin_Click()
If txtuser = "" Then
MsgBox "Please fill in User Name.", vbInformation + vbOKOnly, "Information"
txtuser.SetFocus
Exit Sub
End If

If txtpassword = "" Then
MsgBox "Please fill in Password.", vbInformation + vbOKOnly, "Information"
txtpassword.SetFocus
Exit Sub
End If

Dim SQL As String
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & App.Path & "\数据库名称.mdb"

Adodc1.CommandType = adCmdText
SQL = "select * from 资料表名称 where UserName='" & Trim$(txtuser.Text) & "'And Password='" & Trim$(txtpassword.Text) & "'"
Adodc1.RecordSource = SQL
Adodc1.Refresh

If Adodc1.Recordset.RecordCount <> 0