括号要英文状态下的
添加了表之后就可以添加内容了呀
insert into table_name(这里可要可不要了) values(这里对应的字段数据)
On Error GoTo err1:Dim conn As ADODB.Connection 'conn为连接
Dim rs As New ADODB.Recordset 'rs为记录集
Dim sql As String
Set conn = CreateObject("adodb.connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0Data Source=" &App.Path + "\dat.mdb" &"Jet OLEDB:Database Password=123" '打开数据源
sql = "select * from 学生信息 "
rs.CursorLocation = adUseClient
rs.Open sql, conn, adOpenKeyset, adLockPessimistic
'rs.MoveLast
rs.AddNew'往表中添加新记录
rs.Fields(0).Value = "李振"
rs.Fields(1).Value = 22
rs.Fields(2).Value = "男"
rs.Fields(3).Value = #6/8/1984#
rs.Update
rs.Close
conn.Close
Text1.Text = Text1.Text &Chr(13) &Chr(10) &"记录添加成功~!"
Text1.Text = Text1.Text &Chr(13) &Chr(10) &"记录内容为::"
Text1.Text = Text1.Text &Chr(13) &Chr(10) &" 姓名:李振"
Text1.Text = Text1.Text &Chr(13) &Chr(10) &" 年龄:22"
Text1.Text = Text1.Text &Chr(13) &Chr(10) &" 性别:男"
Text1.Text = Text1.Text &Chr(13) &Chr(10) &" 出生年月:1984-6-8"
Exit Sub
err1:
Text1.Text = Text1.Text &Chr(13) &Chr(10) &Err.Description
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)