Use ADO

  • Thread starter Thread starter Nelva
  • Start date Start date
N

Nelva

Estoy trabajando un Adp, acces 2003, sql server 2000

estoy tratando de adecuar este codigo para que me copie en una tabla fecha
las los fechas que encuentre entre dos fechas...

estoy empezando... la he modificado pero me envia un error.."Variable de
objeto, o bloque with no establecido"

Dim fecha1 As Date
Dim fecha2 As Date
Dim FECHAPRINT
Dim dbs As Database
Dim rs As Recordset
Dim strSQL As String

fecha1 = Me.FechaInicio
fecha2 = Me.FechaFin
'Crear Recorset
strSQL = "Select * from Fecha"
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset(strSQL)
Do While fecha1 <= fecha2
With rs
.AddNew
!fecha = fecha1
.Update
End With
fecha1 = fecha1 + 1
Loop
rs.Close
Set rs = Nothing
 
[omissis]

1) Use english for posting in this newsgroup.
2) You are using DAO, not ADO.
3) You cannot use DAO if you are developing an ADP. You must use ADO.
4) You didn't tell which line of code is raising the mentioned error.
5) You are getting that error because you are trying to use .AddNew method
with a recordset which has not been opened before.
 
Hi Nelva,

try it.
----
Dim fecha1 As Date
Dim fecha2 As Date
Dim rs As New ADODB.Recordset
Dim strSQL As String

fecha1 = Me.FechaInicio
fecha2 = Me.FechaFin

'Crear Recorset
strSQL = "Select * from Fecha Where 1=0"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open strSQL, CurrentProject.Connection

Do While fecha1 <= fecha2
rs.AddNew ("fecha"), Array(fecha1)
fecha1 = fecha1 + 1
Loop
rs.Close
Set rs = Nothing
 
tHANK yoU sO MUCH!






giorgio rancati said:
Hi Nelva,

try it.
----
Dim fecha1 As Date
Dim fecha2 As Date
Dim rs As New ADODB.Recordset
Dim strSQL As String

fecha1 = Me.FechaInicio
fecha2 = Me.FechaFin

'Crear Recorset
strSQL = "Select * from Fecha Where 1=0"
rs.CursorLocation = adUseClient
rs.CursorType = adOpenKeyset
rs.LockType = adLockOptimistic
rs.Open strSQL, CurrentProject.Connection

Do While fecha1 <= fecha2
rs.AddNew ("fecha"), Array(fecha1)
fecha1 = fecha1 + 1
Loop
rs.Close
Set rs = Nothing
----

bye
--
Giorgio Rancati
[Office Access MVP]

Nelva said:
Estoy trabajando un Adp, acces 2003, sql server 2000

estoy tratando de adecuar este codigo para que me copie en una tabla
fecha
las los fechas que encuentre entre dos fechas...

estoy empezando... la he modificado pero me envia un error.."Variable de
objeto, o bloque with no establecido"

Dim fecha1 As Date
Dim fecha2 As Date
Dim FECHAPRINT
Dim dbs As Database
Dim rs As Recordset
Dim strSQL As String

fecha1 = Me.FechaInicio
fecha2 = Me.FechaFin
'Crear Recorset
strSQL = "Select * from Fecha"
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset(strSQL)
Do While fecha1 <= fecha2
With rs
.AddNew
!fecha = fecha1
.Update
End With
fecha1 = fecha1 + 1
Loop
rs.Close
Set rs = Nothing
 
3) You cannot use DAO if you are developing an ADP. You must use ADO.

That's not QUITE true, though I'll admit, there would be precious little
reason to use DAO other than to import non-SQL Server data or something of
that nature.



Rob
 
A good reason would be when you want to port a MDB application with a lot of
DAO code to ADP: creating a DAO database object and use it everywhere you
made a call to CurrentDB in the old application give you the possibility of
having a working application in one or two days instead of one or two
months. Save a lot of money for the client.
 
I had been thinking of a project developed as an ADP from the ground up, but
you're right. In fact, that's exactly how I ported our main database at
work about 1.5 years ago.


Rob
 
Back
Top