3 Replies - 591 Views - Last Post: 31 October 2009 - 01:25 AM Rate Topic: -----

#1 vamudzukwa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-October 09

vb databases

Post icon  Posted 29 October 2009 - 07:39 AM

I am developing a vb6 project and i need to connect it to ms access database
Part of my code is as follows...it gives the error "user defined type not defined"
Help me coz i'm stuck

Dim rs as adodb.recordset
Dim db as adodb.database
Set rs =NewAdodb.recordset
Set db=NewAdodb.database
rs.open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Final Mark Simulator.mdb;"
With rs
.AddNew
.Fields(0)=txtcoursewrk.text

Is This A Good Question/Topic? 0
  • +

Replies To: vb databases

#2 MajorWalrus  Icon User is offline

  • D.I.C Head

Reputation: 10
  • View blog
  • Posts: 115
  • Joined: 22-April 09

Re: vb databases

Posted 29 October 2009 - 02:53 PM

What line is giving you the error?
Was This Post Helpful? 0
  • +
  • -

#3 Guest_evry1falls*


Reputation:

Re: vb databases

Posted 29 October 2009 - 03:44 PM

Quote

In The Name Of ALLAH, The Most Gracious, The Most Merciful


1- In your own code there is something wrong Very Wrong for sure .....
you can not say rs.open "provider = ................ " , because RS Is the table but in this line you must refer to the database .. so it should be like this .... DB.open

2- AnyWay, here is a source code of mine to be able to connect through ADO to Ms Access Database ....

first you need to choose 'Microsoft Active Data Oriented 2.8' from The VB Preferences ....
Second and for your own comfortness ( add module and declare your variable )

Module1
Option Explicit
Global CN as new ADODB.Connection		 ' Connection with DataBase.
Global RS as new ADODB.Recordset		   ' Connection With Table In The DataBase.


Then The Code :

CN.Open "Provider=MICROSOFT.JET.OLEDB.4.0; DATA SOURCE = " & App.Path & "\DBNAME.MDB"	 'Open Connection With DataBase.

RS.open "tablename",CN,,adOpenDynamic ,adLockOptimistic				   'Open Connection With Table .

Was This Post Helpful? 0

#4 ravmonster  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 162
  • Joined: 20-July 09

Re: vb databases

Posted 31 October 2009 - 01:25 AM

maybe this is cause by missing preferences
try this
goto Project then preferences check if the
the microsoft activex data object 2.8 library is check
if it's check then check your codes if not then tik on the check box
then try to run your project again
......................................
post result after performing this.... :D :D :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1