ADO gives others Results then DAO

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
 
G

Guest

I can't test that here, so I can only guess.

If possible, use a separate OLEDB connection for
the ADO, instead of the linked table ODBC connection.

btw, check the scale and precision properties on the
ado recordset, and on the linked table, to see what
ado thinks it is seeing.

Are you sure that ADO is giving the wrong result?
My first guess would be that debug.print is printing the
result wrong, not that ADO is giving the wrong result.

If debug.print is printing the result wrong (or if some
other code is making the same mistake) I would convert
to cdbl() or something else before printing. I would try
to do any calculation inside a sql server stored procedure
before bringing the value out.

(david)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top