2个回答
展开全部
Public Function getColList() As String()
'三个常用的数据库对象
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset, cat As New ADOX.Catalog
'保存列名的数组
Dim strCol() As String, i As Integer
'连接字符串
Dim pstr As String
pstr = "Provider=Microsoft.Jet.OLEDB.4.0;"
pstr = pstr & "Data Source=" & App.Path & "数据库名称"
conn.Open pstr '打开数据库
cat.ActiveConnection = conn 'cat 和conn 连起来
'表对象,adox里的仿简猛
Dim tbl As ADOX.Table
For Each tbl In cat.Tables
ReDim Preserve strCol(i)
strCol(i) = tbl.Name
i = i + 1
Next
getDateList = strDate '将列名数组返回
End Function
---------------------------------
连接字符串要改下,我这个函数是用来连 access 的, SQL可能有点不同.
不备桥过也是大同小异.
如果不明白,可以到我空间看看,收集了一些ADO和ADOX的资料咐烂
'三个常用的数据库对象
Dim conn As New ADODB.Connection, rs As New ADODB.Recordset, cat As New ADOX.Catalog
'保存列名的数组
Dim strCol() As String, i As Integer
'连接字符串
Dim pstr As String
pstr = "Provider=Microsoft.Jet.OLEDB.4.0;"
pstr = pstr & "Data Source=" & App.Path & "数据库名称"
conn.Open pstr '打开数据库
cat.ActiveConnection = conn 'cat 和conn 连起来
'表对象,adox里的仿简猛
Dim tbl As ADOX.Table
For Each tbl In cat.Tables
ReDim Preserve strCol(i)
strCol(i) = tbl.Name
i = i + 1
Next
getDateList = strDate '将列名数组返回
End Function
---------------------------------
连接字符串要改下,我这个函数是用来连 access 的, SQL可能有点不同.
不备桥过也是大同小异.
如果不明白,可以到我空间看看,收集了一些ADO和ADOX的资料咐烂
展开全部
declare @objid int,@objname char(40)
set @objname = 'tablename'
select @objid = id from sysobjects where id = object_id(@objname)
select 'Column_name' = name from syscolumns where id = @objid order by colid
查握友握昌询分析器里输入段皮槐
set @objname = 'tablename'
select @objid = id from sysobjects where id = object_id(@objname)
select 'Column_name' = name from syscolumns where id = @objid order by colid
查握友握昌询分析器里输入段皮槐
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |