VB 6 Help Needed

Status
Not open for further replies.

part_time_ch

Broken In
I am using VB6 with Access for a data entry project.

i have an idea to use MSflexgrid to display the data whenever i save it in the database.

i mean i have a form with four fields and adding and updating the new datas to the database.

i need to display the data automatically in the flexgrid whenever i am clicking the save button.

also the existing datas in the database should appear in the ms flexgrid tool.

please tell me the code to display the records in msflexgrid automatically when i save it to the database.
 
J

javed4shab

Guest
Boss,

You should use a component named :
"Microsoft ADO Data Control 6.0"
This control works best for Data Grid Flex.
1. DRAW ADO CONTROL.
2. RIGHT CLICK on ADO CONTROL.
3. Set Properties.
4. Now Click on Data Grid set it's Datasource property to "adodc1".
5. The Problem will be solved.

If you wish to connect through ADO Code then use :

down load reference " Microsoft Activex Dataobjects 2.0 Library"
Now type following code:

Dim con as new adodb.connection
dim rs as new adodb.recordset
Private sub form_load()
set con = new adodb.connection
with con
.connectionstring = "provider= Microsoft jet 2.0; filename= " 'enter file name
.connectiontimeout = 5
.cursor location = aduseclient
.open
end with
end sub
private sub cmdsave_click() 'cmdsave is name of save command button
rs.open "select * from emp", con, adopendynamic, lockoptimistic, adcmdtext
rs!empno = text1.text 'empno is database field
rs!absg = text2.text
rs.update
set datagrid1.datasource = rs.datasource ' where rs is recordset that you've create.
'and datagrid1 i name of data grid.
end sub
This will Solve your Problem. Enjoy ;-)


JAVED KHAN
IT EXECUTIVE
javed4shab@gmail.com
 
Status
Not open for further replies.
Top Bottom