Vamsi Pavan Mahesh
Vamsi Pavan Mahesh

Reputation: 250

user defined type not defined in vb 6.0

I am trying to connect my vb 6.0 application to the database , so i have declared my data base as Dim dbStu as Database,but while compiling it is giving me error user defined type not defined , i found on another thread that , i need to add the Microsoft Active x Data Objects 2.8 for xp.I have done that too.so now my doubt is am i doing this correct ? should i have to declare those data base variable in form only ?.Or is there anything that is causing the error

Upvotes: 1

Views: 1597

Answers (1)

Hossein Salmanian
Hossein Salmanian

Reputation: 763

you must add a reference to Microsoft Active x Data Objects 2.8 or later then declare an ADODB.Connection and open it with proper ConnectionString value that specify your database path and if it has a password a password value and then you can use this connection object to get data from your database or insert data to it

public cnn As ADODB.Connection
public rs As ADODB.Recordset
Set cnn = New ADODB.Connection
cnn.Open "PROVIDER=MSDataShape;DATA PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=    DatabasePath\DatabaseName.mdb ;Jet OLEDB:Database " 'Password= DataBasePassword ;"

Set rs = New ADODB.Recordset
rs.Open "Select * from FZONE ", cnn, adOpenDynamic, adLockOptimistic

Upvotes: 2

Related Questions