如何获取Access数据库中的表名及其字段名
答案:2 悬赏:80 手机版
解决时间 2021-03-12 01:53
- 提问者网友:溺爱和你
- 2021-03-11 09:53
如何获取Access数据库中的表名及其字段名
最佳答案
- 五星知识达人网友:掌灯师
- 2021-03-11 10:15
写代码解决:
dim rst as new adodb.recordset
rst.open "SELECt * FROM SomeTable", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
dim ii as integer
dim ss as string
for ii = 0 to rst.fields.count - 1
ss = ss & "," & rst.fields(ii).name //循环显示字段
next ii
dim rst as new adodb.recordset
rst.open "SELECt * FROM SomeTable", CurrentProject.Connection, adOpenForwardOnly, adLockReadOnly
dim ii as integer
dim ss as string
for ii = 0 to rst.fields.count - 1
ss = ss & "," & rst.fields(ii).name //循环显示字段
next ii
全部回答
- 1楼网友:思契十里
- 2021-03-11 10:52
sub editfieldname(byval tablename as string, byval fieldname as string, byval newfieldname as string)
on error goto errp
dim tds as tabledefs
dim td as tabledef
dim f as dao.field
set tds = currentdb.tabledefs
set td = tds(tablename)
set f = td.fields(fieldname)
f.properties("name") = newfieldname
exitsub:
set f = nothing
set td = nothing
set tds = nothing
exit sub
errp:
msgbox err.number & " " & err.description
goto exitsub
end sub
三个参数,第一个表名,第二个是原字段名,第三个是新字段名
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯