Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 136,187 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,101 people online right now. Registration is fast and FREE... Join Now!




accessing database using DAO model

 
Reply to this topicStart new topic

accessing database using DAO model

rekha.chaudhari
25 Aug, 2007 - 12:36 AM
Post #1

New D.I.C Head
*

Joined: 25 Aug, 2007
Posts: 1


My Contributions
CODE

dim rs as recordset
dim db as database
form_load()
set db=opendatabase("name of database")
set rs =db.opendatabase("name of table")

but it is giving me error for line 5 i.e set rs.error is of typemismatch

User is offlineProfile CardPM
+Quote Post

MBraybrook
RE: Accessing Database Using DAO Model
26 Aug, 2007 - 06:41 PM
Post #2

New D.I.C Head
*

Joined: 14 Aug, 2006
Posts: 17


My Contributions
What environment are you working in and what database are you trying to access?

You could try changing your dim section to read as follows:
CODE

dim rs as DAO.recordset
dim db as DAO.database


Alternatively, try this link to see if it applies: http://www.dotnet247.com/247reference/msgs/18/90914.aspx

MBraybrook

This post has been edited by MBraybrook: 26 Aug, 2007 - 06:43 PM
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Accessing Database Using DAO Model
26 Aug, 2007 - 08:16 PM
Post #3

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,983



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
Try using this

CODE

Dim rs As Recordset
Dim db As Database
Dim ws As Workspace
Dim db_name As String
Dim sSQL As String

Set db_name = "path to your database here"
Set ws = db.Workspaces(0)
Set db = ws.OpenDatabase(db_name)
Set sSQL = "Your query here"

Set rs = db.OpenRecordset(sSQL)



And see if that solves your problem. I believe you're problem involves using OpenDatabase for both the Database Object and the RecordSet Object.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 01:16AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month