vb向access中如何添加新的数据??????

2024-11-20 20:37:40
推荐回答(1个)
回答1:

先建立连接access数据库,
点“工程”→“引用”→选中“microsoft ActiveX data objects 2.6 Library”点击“确定”
然后用insert into 语句啊
源代码如下
Option Explicit
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strsql As String

Private Sub Command1_Click()
strsql = "insert into Information (name,sex) values('" & Text1.Text & "','" & Text2.Text & "')"
rs.Open strsql, conn, adOpenDynamic, adLockBatchOptimistic
End Sub

Private Sub Form_Load()
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Administrator\桌面\aa.mdb;Persist Security Info=False"
End Sub
自己看看,应该看的懂。