2个回答
展开全部
Dim pubConn As New ADODB.Connection
Dim strconn As String
With pubConn
If .state = adStateClosed Then
strconn = "Provider=SQLOLEDB;User ID=sa; password=sa;Data Source=192.168.0.120\SqlServer;Initial Catalog=fact"
.CursorLocation = adUseClient '设置游标
.Open strconn
End If
End With
strSql = "select * from workshop"
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = pubConn
.CommandText = strSql
.CommandType = adCmdText
Set rsTable = .Execute
End With
While rsTable.EOF = False
Set work = New Workshop
work.workId = rsTable!work_id
work.workName = rsTable!work_name
work.workHead = rsTable!work_head
work.workProhead = rsTable!work_prohead
work.workNumber = rsTable!work_number
'向集合works中添加workshop对象
works.Add work.workId, work.workName
rsTable.MoveNext
Wend
Dim strconn As String
With pubConn
If .state = adStateClosed Then
strconn = "Provider=SQLOLEDB;User ID=sa; password=sa;Data Source=192.168.0.120\SqlServer;Initial Catalog=fact"
.CursorLocation = adUseClient '设置游标
.Open strconn
End If
End With
strSql = "select * from workshop"
Set Cmd = New ADODB.Command
With Cmd
.ActiveConnection = pubConn
.CommandText = strSql
.CommandType = adCmdText
Set rsTable = .Execute
End With
While rsTable.EOF = False
Set work = New Workshop
work.workId = rsTable!work_id
work.workName = rsTable!work_name
work.workHead = rsTable!work_head
work.workProhead = rsTable!work_prohead
work.workNumber = rsTable!work_number
'向集合works中添加workshop对象
works.Add work.workId, work.workName
rsTable.MoveNext
Wend
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询