.


:




:

































 

 

 

 


().




: MoveFirst, MoveLast, MoveNext, Move Previous.

:EOF, BOF. EOF true . BOF.

( recordCount = -1)

Do While Not adors.EOF

Loop

(). Sort . .

adors.Sort = "[_]"

, , .

bm = adors.Bookmark

adors.Bookmark = bm

, , , . #, #.

adors.Find "[ _] = ''"

, Seek. , , CursorLocation Connection adUseClient. Open Options:=adCmdTableDirect. , , , , . , SQL-, . Seek , Find. . , Find. Seek .

- Index. Catalog.

adors.CursorLocation = adUseServer

adors.CursorType = adOpenKeyset

adors.Open "_", Options:=adCmdTableDirect

adors.Index = adocat.Tables("_").Indexes(0).Name

adors.Seek Array(""), adSeekFirstEQ

, . .

adors.Filter = " = ''"

AddNew. , , . . . AddNew: , . .

adors.AddNew Array("_ ", "newcol"), Array("", "113")

Open . , , Execute Command, Connection. . Execute .

Dim cm As ADODB.Command

Set cm = New ADODB.Command

cm.ActiveConnection = adoconn

cm.CommandText = _

"Select * from _ where _=?"

cm.CommandType = adCmdText

Set adors = cm.Execute(Parameters:=Array(""))

xml- UTF-8.

adors.Save "L:/new_zapros1.xml", adPersistXML

 

 

' Set objRecordset = objConn.Execute("SELECT , FROM ")

' SQL, ( , ...)

Set objRecordset = objConn.Execute(", ") '-

Do While Not objRecordset.EOF

Cells(i, 1) = objRecordset.Fields(".").Value

Cells(i, 2) = objRecordset.Fields("").Value

objRecordset.MoveNext '

Loop

 

 

'

' - , ,

' (.. )

' . . .

' "1" , ( ),

' "2" - (, ), ..

' - .

' .

 

 

' : , Access/

' (, , ..... , )

'

' Access , ,

'

 

' , .... WillExecute(Source, CursorType, LockType, Options, adStatus, pCommand, pRecordset, pConnection))

' . , . ,

' , . - ? ?

' , - . ,

 

' ....

'0)

'1)

'2)

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

' : Access

' Dim objConn As ADODB.Connection

' Dim objRecordset As ADODB.Recordset

' Set objConn = CreateObject("ADODB.Connection")

 

' Set objRecordset = objConn.Execute("CREATE TABLE newTable (newColumn INT PRIMARY KEY)")

' ? ()? ?

' : , , , ?

'

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'3) : ,

'4) SQL , : "CREATE TABLE (1 1, 2 2)"

' SQL .

' . SQL "CREATE TABLE " ( ).

' ? ? 3. .

'

' , .

' : . ?

' , ? ?

' .. .( , )

'5) , .,

' , . , "dd/mm/yy;@"

'6) :

'

' Dim objConn As ADODB.Connection

' Set objConn = CreateObject("ADODB.Connection")

'....

'

' objConn.BeginTrans '

'......

' objConn.RollbackTrans '

'......

' objConn.CommitTrans '

' , .

' ' Dim objRecordset As ADODB.Recordset

, . .....

' Dim objRecordset As ADODB.Recordset

Sub ()

' Dim objRecordset As ADODB.Recordset

 

Dim objConn As ADODB.Connection

Dim objRecordset As ADODB.Recordset

Set objConn = CreateObject("ADODB.Connection")

' ConnectString ( - )

ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\111.mdb;Mode=ReadWrite|Share Deny None;Persist Security Info=False"

 

objConn.ConnectionString = ConnectString

objConn.ConnectionTimeout = 15

objConn.CommandTimeout = 30

 

 

objConn.Open

 

 

Dim nstr As Integer

Dim nstolb As Integer

Dim nameFields(30) As String

nstr = 1

Do While Cells(nstr, 1) <> "" And Cells(nstr + 1, 1) <> ""

 

NameTBL = Cells(nstr, 1) '

nstr = nstr + 1

' ( ),

nstolb = 1

NameStolbs = ""

Do While Cells(nstr, nstolb) <> ""

nameFields(nstolb) = Cells(nstr, nstolb)

NameStolbs = NameStolbs & Cells(nstr, nstolb) & " "

Select Case Cells(nstr + 1, nstolb).NumberFormat

Case "dd/mm/yy;@" '

NameStolbs = NameStolbs & "date, "

Case 0

NameStolbs = NameStolbs & "int, "

Case "#,##0.00$" '-

NameStolbs = NameStolbs & "money, "

Case "@" '-

NameStolbs = NameStolbs & "string, "

End Select

 

 

nstolb = nstolb + 1

 

Loop

nstr = nstr + 1

NameStolbs = "(" & Left(NameStolbs, Len(NameStolbs) - 2) & ")"

 

'

otkat = False

objConn.BeginTrans

 

'

 

Set objRecordset = objConn.Execute("CREATE TABLE " & NameTBL & NameStolbs)

' (' WillExecute(Source, CursorType, LockType, Options, adStatus, pCommand, pRecordset, pConnection))

objRecordset.Open NameTBL, objConn, adOpenDynamic, adLockPessimistic

' ( , Update , objRecordset.AddNew "newColumn" = 55654)

 

'

Do While Cells(nstr, 1) <> ""

 

objRecordset.AddNew

For i = 1 To nstolb - 1

objRecordset.Fields(nameFields(i)) = Cells(nstr, i)

' ,

If Cells(nstr, i).Interior.Pattern <> xlNone Then

otkat = True

End If

Next

objRecordset.Update

nstr = nstr + 1

Loop

'

If otkat Then '

objConn.RollbackTrans

Else

'

objConn.CommitTrans

End If

 

Set objRecordset = Nothing

nstr = nstr + 1

Loop

Set objRecordset = Nothing

objConn.Close

Set objConn = Nothing

End Sub

 





:


: 2016-11-18; !; : 339 |


:

:

, .
==> ...

1920 - | 1747 -


© 2015-2024 lektsii.org - -

: 0.049 .