用VBA从excel向access插入数据

2024-12-23 10:29:00
推荐回答(1个)
回答1:

dim cn as adodb.connection
dim tsql as string
set cn=new adodb.connection
cn.open "driver={microsoft access driver (*.mdb)};uid=admin;pwd=;dbq=d:\test.mdb"
tsql="insert into table1(Num,Pname,Sex) values('" + range("B1").value + "','" + range("B5").value + "','" + range("D5") +"')"
cn.execute tsql
set cn=nothing