vb5 versus vb2008

  • Thread starter Thread starter Markus Diehl
  • Start date Start date
M

Markus Diehl

Hi,

was using this piece of source since long in VB5. Now we have to transfer it
into VB2008 and getting a lot of compiler errors. I got mentioned, that DAO
don't work in VB2008. Is there somebody out there who can assist me??


-----------------------------------------------------------------
sub test()


Dim dwBereich As dao.Workspace
Dim dwDatenbank As dao.Database
Dim dwTabelle As dao.Recordset
Dim ws As dao.Workspace

Set dwDatenbank = ws.OpenDatabase(DB_Path & DB_name)
dwTabelle = dwDatenbank.OpenRecordset("austria")
dwBereich.BeginTrans()

For I = 1 To 100
dwTabelle.AddNew()

dwTabelle![au_Datum] = Big_au_Datum(I)
dwTabelle![au_Mobile] = Big_au_Mobile(I)
dwTabelle![au_client] = Big_au_Kundennummer(I)

dwTabelle.Update()
Next I

dwBereich.CommitTrans()
dwTabelle.Close()
end sub
-----------------------------------------------------------
 
Markus Diehl said:
Hi,

was using this piece of source since long in VB5. Now we have to transfer
it into VB2008 and getting a lot of compiler errors. I got mentioned, that
DAO don't work in VB2008. Is there somebody out there who can assist me??


-----------------------------------------------------------------
sub test()


Dim dwBereich As dao.Workspace
Dim dwDatenbank As dao.Database
Dim dwTabelle As dao.Recordset
Dim ws As dao.Workspace

Set dwDatenbank = ws.OpenDatabase(DB_Path & DB_name)
dwTabelle = dwDatenbank.OpenRecordset("austria")
dwBereich.BeginTrans()

For I = 1 To 100
dwTabelle.AddNew()

dwTabelle![au_Datum] = Big_au_Datum(I)
dwTabelle![au_Mobile] = Big_au_Mobile(I)
dwTabelle![au_client] = Big_au_Kundennummer(I)

dwTabelle.Update()
Next I

dwBereich.CommitTrans()
dwTabelle.Close()
end sub
-----------------------------------------------------------

I see 2 problems. First, you are not initialising ws to be a WorkSpace. Try
adding this line before the 'Set dwDatenbank =' line:

Set ws = DAO.WorkSpaces(0)

Also dwBereich is uninitialised, but you don't actually need it. Use ws
instead:

ws.BeginTrans()

and:

ws.CommitTrans()
 
Back
Top