T
Toontje
I've made a table in sql server(2000) with the name Test with the
following fields
ID Decimal Precision 18 scale 0 Identity=Yes
W1 Decimal Precision 18 scale 4
W2 Decimal Precision 18 scale 2
W3 Money
W4 Float
When I run next function the results from ADO and DAO are different.
Can someone explain me why?
Public Function TestData()
Dim db As Database
Dim rstADO As ADODB.Recordset
Dim rstDAO As DAO.Recordset
Set db = CurrentDb
Set rstDAO = db.OpenRecordset("SELECT * FROM dbo_Test",
DB_OPEN_DYNASET)
rstDAO.AddNew
rstDAO!W1 = 5 / 4
rstDAO!W2 = 5 / 4
rstDAO!W3 = 5 / 4
rstDAO!W4 = 5 / 4
rstDAO.Update
rstDAO.Close
Set rstDAO = db.OpenRecordset("SELECT * FROM dbo_Test",
DB_OPEN_DYNASET)
Do While Not rstDAO.EOF
Debug.Print "DAO W1: " & rstDAO!W1
Debug.Print "DAO W2: " & rstDAO!W2
Debug.Print "DAO W3: " & rstDAO!W3
Debug.Print "DAO W4: " & rstDAO!W4
rstDAO.Delete
rstDAO.MoveNext
Loop
rstDAO.Close
Set rstADO = New ADODB.Recordset
rstADO.CursorLocation = adUseClient
rstADO.Open "SELECT * FROM dbo_Test", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
'
rstADO.AddNew
rstADO!W1 = 5 / 4
rstADO!W2 = 5 / 4
rstADO!W3 = 5 / 4
rstADO!W4 = 5 / 4
rstADO.Update
rstADO.Close
rstADO.Open "SELECT * FROM dbo_Test", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
Do While Not rstADO.EOF
Debug.Print "ADO W1: " & rstADO!W1
Debug.Print "ADO W2: " & rstADO!W2
Debug.Print "ADO W3: " & rstADO!W3
Debug.Print "ADO W4: " & rstADO!W4
rstADO.Delete
rstADO.MoveNext
Loop
End Function
Result of function
DAO W1: 1,25
DAO W2: 1,25
DAO W3: 1,25
DAO W4: 1,25
ADO W1: 12500
ADO W2: 125
ADO W3: 1,25
ADO W4: 1,25
following fields
ID Decimal Precision 18 scale 0 Identity=Yes
W1 Decimal Precision 18 scale 4
W2 Decimal Precision 18 scale 2
W3 Money
W4 Float
When I run next function the results from ADO and DAO are different.
Can someone explain me why?
Public Function TestData()
Dim db As Database
Dim rstADO As ADODB.Recordset
Dim rstDAO As DAO.Recordset
Set db = CurrentDb
Set rstDAO = db.OpenRecordset("SELECT * FROM dbo_Test",
DB_OPEN_DYNASET)
rstDAO.AddNew
rstDAO!W1 = 5 / 4
rstDAO!W2 = 5 / 4
rstDAO!W3 = 5 / 4
rstDAO!W4 = 5 / 4
rstDAO.Update
rstDAO.Close
Set rstDAO = db.OpenRecordset("SELECT * FROM dbo_Test",
DB_OPEN_DYNASET)
Do While Not rstDAO.EOF
Debug.Print "DAO W1: " & rstDAO!W1
Debug.Print "DAO W2: " & rstDAO!W2
Debug.Print "DAO W3: " & rstDAO!W3
Debug.Print "DAO W4: " & rstDAO!W4
rstDAO.Delete
rstDAO.MoveNext
Loop
rstDAO.Close
Set rstADO = New ADODB.Recordset
rstADO.CursorLocation = adUseClient
rstADO.Open "SELECT * FROM dbo_Test", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
'
rstADO.AddNew
rstADO!W1 = 5 / 4
rstADO!W2 = 5 / 4
rstADO!W3 = 5 / 4
rstADO!W4 = 5 / 4
rstADO.Update
rstADO.Close
rstADO.Open "SELECT * FROM dbo_Test", CurrentProject.Connection,
adOpenKeyset, adLockOptimistic
Do While Not rstADO.EOF
Debug.Print "ADO W1: " & rstADO!W1
Debug.Print "ADO W2: " & rstADO!W2
Debug.Print "ADO W3: " & rstADO!W3
Debug.Print "ADO W4: " & rstADO!W4
rstADO.Delete
rstADO.MoveNext
Loop
End Function
Result of function
DAO W1: 1,25
DAO W2: 1,25
DAO W3: 1,25
DAO W4: 1,25
ADO W1: 12500
ADO W2: 125
ADO W3: 1,25
ADO W4: 1,25