[求助]数据库 写入问题
本帖最后由 作者 于 2003-3-31 23:06:32 编辑您好
我请教一下利用vba连接数据库的问题
我现在知道如何从数据库中读数据,如下
driver = "{Microsoft Access Driver (*.mdb)}"
dbq = "D:\leo\a.mdb"
conn.Open "driver=" & driver & ";dbq=" & dbq
Set cmd.ActiveConnection = conn
cmd.CommandText = "SELECT * from esca"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockBatchOptimistic
但我不知如何写数据入库,我只知sql的格式为
INSERT INTO mysheet VALUES ('zhanghua','18','student')
但如何将此格式用于vba中
请多指教
如下:
Set cmd.ActiveConnection = conncmd.CommandText ="insert into mysheet VALUES ('zhanghua','18','student')"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockBatchOptimistic
或
conn.excutex "INSERT INTO mysheet VALUES ( 'zhanghua','18','student') "
页:
[1]