VB连接数据库SQL sever
生活随笔
收集整理的這篇文章主要介紹了
VB连接数据库SQL sever
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
現在數據庫建立新庫用于存放數據(導航貓或visual studio)
定義鏈接
Dim?a As New ADODB.Connection?
Dim rs As New ADODB.Recordset
打開連接
a.ConnectionString = "Provider=SQLOLEDB;Password=sas;Persist Security Info=False;User ID=sa;Initial Catalog=Department_DB;Data Source=192.168.aa,aaa"
a.Open
?If rs.State <> adStateClosed Then
??????? rs.Close
?End If
?rs.Open SQL, hg, adOpenKeyset, adLockPessimistic
? ans = rs.GetRows
??? hang = rs.RecordCount
??? lie = 9
With ActiveSheet
??? For i = 0 To hang - 1
??????? For j = 0 To lie - 1
??????????? .Cells(i + 2, j + 1).Value = ans(j, i)
??????? Next
??? Next
??? End With
?
?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的VB连接数据库SQL sever的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 有哪些工具或者软件堪称神器?
- 下一篇: 【eoeAndroid社区索引】andr