ADP and SQL Express

S

Steven Cheng

I just recently i migrated on my Access database to SQL Express 2005 and
trying to connect to the databases with the following:

Private Sub testing()
Dim strconnect As String
Dim r As String

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset

strconnect = "Provider=SQLOLEDB;Integrated Security=SSPI;Initial
Catalog=Telephone;Data Source=PH-XP01\SQLEXPRESS"

Set cn = New ADODB.Connection
cn.ConnectionString = strconnect
cn.Open
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "Select * from Accsum_30987_20080304"
.Open
.MoveLast
MsgBox .RecordCount, vbOKOnly
End With


End Sub

i keep getting an error message upon trying to execute the movelast
statement where the error message reads:
Row set does not support fetching backward.

can someone please explain where i have gone wrong here as i was able to
retrieve the field names from the table, but can move through the table like
i had with DAO.

Steven
 
J

Josef Poetzl

hi,

Steven said:
I just recently i migrated on my Access database to SQL Express 2005 and
trying to connect to the databases with the following:

Private Sub testing() [...]
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "Select * from Accsum_30987_20080304"
.Open
.MoveLast
MsgBox .RecordCount, vbOKOnly
End With

End Sub

i keep getting an error message upon trying to execute the movelast
statement where the error message reads:
Row set does not support fetching backward.

The default cursortype adOpenForwardOnly does not support movelast.
see http://msdn.microsoft.com/en-us/library/ms677593(VS.85).aspx
=>
with rs
...
.CursorType = adOpenStatic ' or adOpenKeyset
.open
.movelast
...
end with


kind regards,
Josef
 

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