ITYourself! - компьютерная документация, книги, мануалы, it-тематика

??????? ?? Visual Basic - 12.5. ?????? ? ????? ?????? ????? ??????? ADODB.

E-mail Печать PDF
Рейтинг пользователей: / 984
ХудшийЛучший 
Индекс материала
??????? ?? Visual Basic
1.2. ???????????? ? ?????????? VB
1.3. ?????? VB.
1.4. ??????????????? ????? ?????????? (IDE - Integrated Development Environment)
1.5. ???????? ??????????? ?????.
2. ???? ??????. ?????????? ? ?????????, ?? ??????? ?????????. ???????.
2.2. ?????????? ? ?????????, ?? ??????? ?????????.
2.3. ?????????? ???????? ? ?????? ? ????.
3. ???????? ????
3.1. ???????? ???????????? ????
3.2. ???????? ??????????-?????????? ????
5. ?????????? ?????????? Drag&Drop ?????????? VB
5.1. ??????? Drag&Drop
5.2. ??????? Drag&Drop
5.3. ?????????????? ??????????????
5.4. ?????????????? ? ?????????????? OLE
5.5. ?????????????? ?????????????? ? ?????????????? OLE
5.5. ??????????????? ?????????????? ? ?????????????? OLE
6. ?????? ? ???????? ? Visual Basic.
6.1.1. ?????????? ? ????? ???????.
6.1.2. ?????????? ? ????? ???????.
6.1.3.?????????? ? ????? ???????.
6.1.4.?????????? ? ????????????? ????????.
6.1.5. ???????? ??????? ??????.
6.2. ??????????????? ?????? - ????????? ?????? Splitter.
7. ?????????? OLE
7.1. ??????? ?????????? OLE Container
7.2. ??????? OLE ??? ???????? ??????????
7.3. OLE Automation
7.4. ???????? ??????? OLE
7.5. ????????????? ??????? OLE
7.6. ?????? ? ????????? Word
8. ???????? ????????? ?????????? Active X.
???????? ????????? ?????????? ActiveX
???????? ????????? ?????????? Active X ?? ??????? ZigZag.
9. ????????????? ??????? Windows API ? VB.
API-??????
10. ???????? ??????? ? Visual Basic.
10.2. ????????? ????????? ?????????? (????? ????????????????? ???????).
10.3. ????? ????????????? (???????) ???????.
10.4. ????? ?????????????.
10.5. ????????????? FSO (File System Object).
11. ????????????? ???????? ?????????? WinSock Control ??? ???????? ??????? ??????????.
12. ?????? ? ????? ?????? ?? VB ? ??????? ADO.
12.2. ?????? ?????????? ??????? - ADO Data Control.
12.3. ????????? ? ??????? ???????? ??????????.
12.4. ????????????? Data Grid Control.
12.5. ?????? ? ????? ?????? ????? ??????? ADODB.
13. ????????
Все страницы

5. ?????? ? ????? ?????? ????? ??????? ADODB.

????????? ?????? ADO ?????????? ????? (?????????) ??????????????? ????????, ??????? ????? ?????????????? ? Visual Basic, Visual C++, VBScripting, Java ?? ????? ?????????, ??????? ???????????? COM ? ????????????? OLE. ????????? ?????? ADO ??????????? ??? ?????????? ??????????? ???????????? OLE DB.

ADO ???????? ???? ????????:

  • Connection
  • Command
  • Parameter
  • Recordset
  • Field
  • Property
  • Error

? ?????? ?????? ???????? (?????????):

  • Fields
  • Properties
  • Parameters
  • Errors

??????? Connection, Recordset ? Command ???????? ????????? ????????? ? ????????? ?????? ADO. ADO ?????????? ????? ???????????? ?????? Connection ??? ????????? ?????????? ? ???????? ??, ?????? Command - ??? ?????? ??????? ? ??, ????? ??? ???????, ?????????? ? ?.?. ? ?????? Recordset - ??? ????????? ? ??????????????? ???????. ????????? ????, ???????????? ? ???????? Command, ??????? ?? ?????????? ??? ??. ? ?????? ??????????? ??? ?????? ? ???????? ?????????? ????? ????????? SQL.

? ?????? ???????? Errors ? ??????? Error ????? ???????? ?????? ????? ?????? Connection ????? ???? ??? ????????? ?????? ??????????. ? ?????? ???????? Fields ? ??????? Field ????? ???????? ?????? ????? ?????? Recordset ????? ???? ??? ? ??????? Recordset ???????? ?????-???? ??????. ?????????? ? ?????????? ??????? Recordset ????? ???? ??????????? ????? ????? ???????? Fields ? ?????? Field.

 

?????? Connection.

?????? Connection ????????? ????????????? ?????? ????? ? ??????????? ??????. ?????? Connection ???????????? ???????? ??? ????????????? ? ???????????? ??????????, ?????????? ???????? ? ????????????? ??????????.

????? Open ??????? Connection ???????????? ??? ????????? ??????????. ????? ??????????? ?????????? ????? ?????????? ?????? ??????????, ????-??? ??????????, ?? ?? ????????? ? ???????? ??????????. ?????? Connection ??? ?? ????????? ?????????? ???????? CommandTimeout ??? ???? ????????? ????????, ????????? ? ?????? ???????????. ?????????? ?????? Open ???????? ?????? ??????????. ??? ????, ????? ????? ?? ????????, ???????? ?? ????? ????????? ??????? ADO Data Control ? ???????? ? ??????? ??????? ?????? ??????????. ????? ?????? ?????????? ?? ? ??????????? ? ?????? Open, ? ????????? ?????? ???????.

??????? ???? ??????????? ? ?????????????? ?????? Execute.

????? ?????? ? ?? ?????????? ??????? ?????????? ??????? Close ? ???????? ?????????? ???? ADODB.Connection.

??????:

Dim Conn1 as ADODB.Connection

Conn1 = New ADODB.Connection

Conn1.ConnectionTimeout = 100

Conn1.Open "Driver={SQL Server};Server=Server1;Uid=sa;Pwd=;Database=pubs"

Conn1.Execute "DELETE * FROM Table1"

Conn1.Close

Conn1 = Nothing

 

?????? Command.

?????? Command ????????? ?????????? ??????? ? ??. ??? ??????? ????? ???????? ?????? ???????? ? ????????? ? ????????? ?????????, ?? ?? ?????????????? ?????? ?????????.

?????? Command ????? ??? ????????? ????? ??????????, ??? ? ???????????? ??? ???????????? ?????????? ??? ?????????? ????????, ? ??????????? ?? ????????? ???????? ActiveConnection. ???? ???????? ActiveConnection ??????????? ? ??????? ?? ?????? Connection, ?? ?????? Command ????? ???????????? ???????????? ?????????? ?? ??????? Connection. ???? ???????? ActiveConnection ???????????? ??????? ??????????, ?? ??? ??????? Command ????? ??????????? ????? ??????????. ??? ?????? ??????? Connection ????? ?????????????? ????????? ???????? Command.

?????????? ???????? ????? ???????????? ????? ???????, ????????????? ?????? ??????? ??? ?? ???????????? ??????? ???????. ????????, ?????????? ???????? ????? ???????? ?????? (data definition language - DDL) ?? ?????????? ??????? ???????. ?????????? ????????? SELECT ????? ???????????? ????? ??????? ? ?????????? ?????? SELECT ?????????? ??? ???????? ????????? ?????????? ????? ??? ???? ????? ???????.

?????? ??????? ???????????? ????????? CommandText. ?????? ??????? ????? ???? ?????????? ?? ??????????? ????? ??????????????? ??????? (data manipulation language - DML) ? ?????????????? SELECT, INSERT, DELETE, ??? UPDATE ?????????? ??? ?? ????? ???????? ??????, ???????? CREATE ??? DROP. ? ?????? ??????? ????? ????? ???? ??? ???????? ????????? ??? ???????.

??? ?????? ??????? ???????????? ????????? CommandType. ???????? ???????? CommandType ????? ???? ??????????: adCmdText, adCmdTable, adCmdStoreProc ? adCmdUnknown. ????? ??????? ??????? ???????? SQL ????????, ???????? CommandType ?????? ???????????? ??? adCmdText. ???????? adCmdStoreProc ??? adCmdTable ???????????, ???? ?????? ??????? ???????????? ??? ???????? ????????? ??? ??? ???????.

? ????????? ??????? ???????? ?????????? ????????? SELECT, ??????? ?????????? ?????? Recordset:

Dim Comm1 as ADODB.Command

Dim Rsc1 as ADODB.RecordSet

Comm1 = New ADODB.Command

Comm1.ActiveConnection="Driver={SQL Server};Server=Server1;Uid=sa;Pwd=; " & _

"Database=pubs"

Comm1.CommandText= "SELECT * FROM Table1"

Comm1.CommandTimeout=15

Comm1.CommandType = adCmdText

Set Rsc1 = Comm1.Execute()

?????? ? Rsc1

...

Rsc1.Close

Comm1.Close

Comm1 = Nothing

Rsc1 = Nothing

?????? RecordSet.

?????? Recordset ???????????? ?????? ??? ??????????????? ???????? ??????. ?????? Recordset ????????? ?????????, ???????, ????????? ?????? ? ???????????? ?? ??????? ??????? ??????. ? ??????? ?????? ???????? Fields ? ??????? Field ????? ???????? ?????? ? ????? ?????????? ??????. ?????????? ??????? Recordset ????? ???? ??????? ?????????? ??? ? ???????? ??????. ??? ???????? ??????? Recordset ????????????? ??????????? ??????.

?????? Recordset ????????? ?????????? ??? ??????? ???? ???????????? ??? ?????? ??????????????? ?????? ??????. ????????? ???????? CursorType ????? ?????????? ??? ???????: forward-only, static, keyset-driven, ??? dynamic. ??? ??????? ?????????? ????????? ??????? Recordset ??? ????????? ??????? ??????/????? ??? ??? ?????????? ???????. ??? ??????? ????? ?????? ?? ????????? ?????????? ???????.

?? ????????? ??? ??????? ??????????????? ? forward-only ?????? ??? ??????. ???? ?????????? ?????? ?????? ?????? ? ???????????????? ?????? (forward), ?? ???????? ??? ??????? ?? ???????. ? ?????? ???????, ????? ?????????? ??? ??????? ? ??????????? ?? ???????? ??????.

????? ???????? Fields ? ?????? Field

????? ???????? Fields ? ?????? Field ????????? ???????? ?????? ? ?????? ????? ??????? ? ??????? ??????. ? ?????? ???????? Fields ????? ???????? ?????? ????? ?????? Recordset. ? ??????? Field ????? ???????? ?????? ????? ????? ???????? Fields ????????? ??????. ?????? Field ????? ???????????? ??? ??????????? ????? ?????? ??? ??? ????????? ??? ???????????? ?????? ? ????? ???????????? ?????? AddNew, Update ??? UpdateBatch ??????? Recordset ??? ??????? ????? ??? ????????? ???????????? ??????.

??????:

Dim Comm1 as ADODB.Command

Dim Rsc1 as ADODB.RecordSet

Dim Fld1 as ADODB.Field

Comm1 = New ADODB.Command

Comm1.ActiveConnection="Driver={SQL Server};Server=Server1;Uid=sa;Pwd=; " & _

"Database=pubs"

Comm1.CommandText= "SELECT * FROM Table1"

Comm1.CommandTimeout=15

Comm1.CommandType = adCmdText

Set Rsc1 = Comm1.Execute()

?????? ? Rsc1

For Each Fld1 In Rsc1.Fields

Debug.Print Fld1.Name

Debug.Print Fld1.Type

Debug.Print Fld1.Value

Next

Rsc1.Close

Comm1.Close

Comm1 = Nothing

Rsc1 = Nothing

Fld1=Nothing

???????? ?? RecordSet'? ?????????????? ? ??????? ????????? ??????? ????? ???????:

  • BOF (?????????? True ??? False)
  • EOF (??????????, ?????? ????? ???????)
  • MoveNext
  • MoveFirst
  • MovePrevious
  • MoveLast
  • Move(number)

????? ???????, ???????? ?? ???? ??????? ? ?????? ????? ????????? ???????:

Dim Comm1 as ADODB.Command

Dim Rsc1 as ADODB.RecordSet

Comm1 = New ADODB.Command

Comm1.ActiveConnection="Driver={SQL Server};Server=Server1;Uid=sa;Pwd=; " & _

"Database=pubs"

Comm1.CommandText= "SELECT * FROM Table1"

Comm1.CommandTimeout=15

Comm1.CommandType = adCmdText

Set Rsc1 = Comm1.Execute()

?????? ? Rsc1

Rsc1.MoveFirst

Do While Not (Rsc1.EOF)

... ?????-?? ???????? ? ??????? ???????

Rsc1.MoveNext

Loop

Rsc1.Close

Comm1.Close

Comm1 = Nothing

Rsc1 = Nothing

 



 

???????????

??????????




????????

Внимание!!! Файл sape.php не обнаружен. Проверьте правильность установки кода Sape.


C???????? ?????????