ВУЗ:
Составители:
Рубрика:
61
метода Open объекта Recordset. Для иллюстрации этого служит итерация по записям
набора, организованная при помощи цикла DO UNTIL ... LOOP. В заключение примера
освобождается память и ресурсы, занятые объектами.
Dim MyConn As ADODB.Connection
Dim MyRec As ADODB. Recordset
Dim ConStr As String
Dim MyComm AS ADODB.Command
ConStr="Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb"
Set MyConn= New ADODB.Connection
Set MyRec = New ADODB.Recordset
MyConn.Open ConStr
Set MyComm = New ADODB.Command
MyCommand.ActiveConnection = MyConn
MyComm.CommandText = "[Временная];"
MyComm.CommandType = adCmdTable
Set MyRec = MyComm. Execute
Do Until MyRec.EOF
Debug.Print MyRec![КодКлиента]
MyRec.MoveNext
Loop
MyRec.Close
MyConn.Close
Set MyConn = Nothing
Set MyComm = Nothing
Set MyRec = Nothing
Примеры использования объекта Command
Пример 1
Dim res As New Collection
Dim conn As ADODB.Connection
Dim cmd As New ADODB.Command
Set conn = Access.CurrentProject.AccessConnection
cmd.ActiveConnection = conn
cmd.CommandText = "SELECT p.Name AS DependencyName FROM (Dependencies AS d
INNER JOIN Packages AS p ON d.DependencyID=p.PackageID) INNER JOIN Packages AS pd
ON pd.PackageID=d.DependentID WHERE d.DependentID = (SELECT PackageID from Packages
Where Name = @Name)"
cmd.Parameters("@Name").Value = packageName
Dim rs As ADODB.Recordset
Set rs = cmd.Execute
Do While Not rs.EOF
res.Add (rs("DependencyName").Value)
rs.MoveNext
Loop
conn.Close
метода Open объекта Recordset. Для иллюстрации этого служит итерация по записям набора, организованная при помощи цикла DO UNTIL ... LOOP. В заключение примера освобождается память и ресурсы, занятые объектами. Dim MyConn As ADODB.Connection Dim MyRec As ADODB. Recordset Dim ConStr As String Dim MyComm AS ADODB.Command ConStr="Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\db2.mdb" Set MyConn= New ADODB.Connection Set MyRec = New ADODB.Recordset MyConn.Open ConStr Set MyComm = New ADODB.Command MyCommand.ActiveConnection = MyConn MyComm.CommandText = "[Временная];" MyComm.CommandType = adCmdTable Set MyRec = MyComm. Execute Do Until MyRec.EOF Debug.Print MyRec![КодКлиента] MyRec.MoveNext Loop MyRec.Close MyConn.Close Set MyConn = Nothing Set MyComm = Nothing Set MyRec = Nothing Примеры использования объекта Command Пример 1 Dim res As New Collection Dim conn As ADODB.Connection Dim cmd As New ADODB.Command Set conn = Access.CurrentProject.AccessConnection cmd.ActiveConnection = conn cmd.CommandText = "SELECT p.Name AS DependencyName FROM (Dependencies AS d INNER JOIN Packages AS p ON d.DependencyID=p.PackageID) INNER JOIN Packages AS pd ON pd.PackageID=d.DependentID WHERE d.DependentID = (SELECT PackageID from Packages Where Name = @Name)" cmd.Parameters("@Name").Value = packageName Dim rs As ADODB.Recordset Set rs = cmd.Execute Do While Not rs.EOF res.Add (rs("DependencyName").Value) rs.MoveNext Loop conn.Close 61
Страницы
- « первая
- ‹ предыдущая
- …
- 59
- 60
- 61
- 62
- 63
- …
- следующая ›
- последняя »