欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

怎樣用excelVBA將sql數(shù)據(jù)庫中數(shù)據(jù)的列名讀

錢多多2年前15瀏覽0評論

怎樣用excelVBA將sql數(shù)據(jù)庫中數(shù)據(jù)的列名讀?

Sub 按鈕1_Click()

Dim i As Integer, j As Integer, sht As Worksheet 'i,j為整數(shù)變量;sht 為excel工作表對象變量,指向某一工作表

'Dim cn As New ADODB.Connection '定義數(shù)據(jù)鏈接對象 ,保存連接數(shù)據(jù)庫信息;請先添加ADO引用

'Dim rs As New ADODB.Recordset '定義記錄集對象,保存數(shù)據(jù)表

‘工具 ---〉引用 ---〉Microsoft ActiveX data objects ....

'下面兩句就不需要增加引用ADO

Set cn = CreateObject("Adodb.Connection")

Set rs = CreateObject("Adodb.Recordset")

Dim strCn As String, strSQL As String '字符串變量

Dim strCond As String

strCn = "Provider=sqloledb;Server=R9HDET7;Database=dbname;Uid=username;Pwd=password" '定義數(shù)據(jù)庫鏈接字符串