Web Development

General discussion


VB6 and ADODC Object Control

By kojosteve ·
Each time i try to connect my form on VB6 to a database in Access
2000, i am unable to access the fields.
What are the steps i need to follow
Thank you

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

VB6 and ADODC Object Control

by RRV In reply to VB6 and ADODC Object Cont ...

1) Install VB SP5.
2) Use Jet driver 4.0 to connect to your database in ADODB
3) Open a ADODB recordset or use seek method to get data from a table or view.
4) "For each flddb in Recordset.fields" will give access to all fields of the open table.

[To do the below line have a reference to MS actX Data Objects 2.7 Library]
dim DB as adodb.Connection
dim Rs as adodb.Recordset
set DB=new ADODB.Connection
DB.Open "Data Provider=Microsoft.Jet.OLEDB.4.0;Data Source=mdb path;User ID=Admin;Jet OLEDB:Database Password='password';Persist Security Info=false;Locale Identifier=1033"
set Rs=new ADodb.Recordset
rs.open "select T1.fld1,T2.fld2 from ((T2 right join T1 on T1.fld1=T2.fld2)) where T.Ffld1="xyz", DB,adOpenForwardOnly,adLockReadOnly

'Now you have full RS recordset
dim fldOpr as ADODB.Field
dim fldProp as ADODB.Property

for each fldOpr in RS.fields
for each fldProp in fldOpr.Properties
msgbox "Field : " & fldOpr & " - Property : " & fldProp.Value & "(" & fldProp.Type & ")"

So copy the above code in your VB and change appropriate fields. It will definitely work.

Collapse -

VB6 and ADODC Object Control

by Miss Kitty In reply to VB6 and ADODC Object Cont ...

On your form, I assume you have installed a ADODC control. On the properties of the control make sure you have selected
1. Use connection string and click on build.
2. Provider=Microsoft.Jet.OLEDB.4.0;
3. Test the connection. If it comes back ok then you should be able to connect text boxes on your form to the database table.
4. In your text box properties, set the datasource to the ado control and your datafield to the table field you want.

Collapse -

VB6 and ADODC Object Control

by itpreneur In reply to VB6 and ADODC Object Cont ...

I assume two things:
A..If you are working in design time and put ADODC object control in your forms. You should do the following:
B. sELECT adodc properties
Choose ODBC if you have setup data source name.
or choose build connection string and select OLEDB OR Microsoft Jet 3.5/4.0 and choose the Access file name.
By then, VB will point you to recordsource and commandtype=TABLE and choose the table name. or you can use commandtype=TEXT and put an sql statement like this select * from tablename.

If you want programming, you can write the following short code.

Dim cmd As New ADODB.Command, rs As New ADODB.Recordset
cmd.ActiveConnection = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=SSA"

'add the database
Dim sqlsource As String

sqlsource = "SELECT fieldname FROM tblname "
cmd.CommandType = adCmdText
cmd.CommandText = sqlsource
Set rs = cmd.Execute()

Related Discussions

Related Forums