Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb and database

Status
Not open for further replies.

horoscope

Technical User
Dec 1, 2002
17
CN
Dim db As Database
Dim rec As Recordset
Set db = OpenDatabase(App.Path & "\Database\UsersDB.mdb" _
, False, False, ";pwd=AdmiN")
Set rec = db.OpenRecordset("Users", dbOpenTable)
why before codes make error?
anyone can tell me?
 
Can you please specify the error you are getting? Are you sure you have all the right references selected?

Swi
 
Set rec = db.OpenRecordset("Users", dbOpenTable)
from the test is the before syntax has error.
the error information is
realtime error '13'
can anyone know why.
 
db.OpenRecordset expects an SQL statement - 1 parameter only - as in db.OpenRecordset("Select * From Table").
 
I created a database and a table within it just like your example and the code worked fine.

Dim db As DAO.Database
Dim rec As DAO.Recordset
Set db = OpenDatabase("C:\UsersDB.mdb" _
, False, False, ";pwd=AdmiN")
Set rec = db.OpenRecordset("Users", dbOpenTable)

Make sure you add a reference to Microsoft DAO X.X Object Library. Also make sure that your database exists and that the table that you are referencing exists as well.


Swi
 
db.OpenRecordset expects an SQL statement"

Actually, horoscope's code will work as is.

Swi
 
i use
Dim db As DAO.Database
Dim rec As DAO.Recordset
instead of
Dim db As Database
Dim rec As Recordset
the code works well.
why?
what's the difference between DAo.database and database
?
 
hi man
i have a problem of connecting my db how to make a Database server and a DB client , give me just an example in acees or VB if possible
 
horoscope, the following code will work for me as well. You just need to make sure you have a reference set for Microsoft DAO X.X Object Library.

Dim db As Database
Dim rec As Recordset
Set db = OpenDatabase("C:\UsersDB.mdb" _
, False, False, ";pwd=AdmiN")
Set rec = db.OpenRecordset("Users", dbOpenTable)
MsgBox rec.Fields(0).Value

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top