Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Sunday, August 14, 2011

VB-108 : How to see Data in Grid

This program is connected with the below given 2 programs also...
So , You must refer them while doing the third Program.
They are ;

  1. To create Reports using Data Reports
  2.  Program using ADO Data Control

==========================================================
Here , we are going to view Data in Grid Control
 Add a Form and a MDI Form for this Project.
  • Form
  • MDI Form 
=========================================================================
Details about adding Forms : 



(If we want , we can add the 2 Forms  ,as we did in Program using ADO Data Control ,then we can add/modify the data).


Here , I am doing the method to view the fields in Grid Form.
 If you are placing Form1 & Form2 also , then add the new Form as Form3 and   place a Data Grid Control.

=========================================================================
(A) Program  Design :


Form
(Add One Data Grid Control ,One ADO Data Control , and one Command Button with Caption OK
Select Project-->Components--> Microsoft DataGrid Control 6.0 ,  to place a Data Grid Control



MDI Form
Project-->Add MDI
Then select Tools--> Menu Editor . Create a Menu as per shown below:
 (Create a menu with Student , Report and Exit as the Main menus)






The created Menu Bar in MDI form will look like this :


--------------------------------------------------------------------------------------------

(B) To Design a Database for this Program :

Now we are going to create a Database as per the above given details :as we did in Program using ADO Data Control 

We are creating this in MS-Access.
(You can Refer Linking to Database also to know How to create a Database in Access)

  • Open MS Access
  • Select Blank Database , give a name and click Create(Here , we are giving a file name -Student)
  • Create table in Design view
  • Give Details 
It will look like this :



Then File --> Save ( Note that , the Table Name is Student)
--------------------------------------------------------------------------------------------
(C) Now,we are going to connect this Database & VB


(1) Connecting ADODC of Form:

  • Select  Form
  • Right Click on ADODC to get its Properties
(Refer Creating Database within VB Platform and note Point Number (4) , "How to connect ADO DataControl with Database" , to know more about ADODC Properties)
  • Now , we will get a Property Page , select Use Connection String and  Click Build 
  • And we will lead to Data Link Property pages , and select Microsoft Jet 4.0 OLEDB Providerand Click Next
  • Select the created Database Name (Here, we created Student) , and Click Test Connection to know whether the connection is right.Click OK
  • Again , back to Property Page , select Record Sourse , and select 2-adCmdTable and select table (Student)
  • Apply , OK
======================

(2) Connecting DataGrid of Form:


Select Data Source Property to Adodc1


======================
(C) Now,we are going to write Code :


(1) Code for MDI Form :

Private Sub mnudetails_Click()
Form3.Show
End Sub
Private Sub mnuexit_Click()
End
End Sub



(2) Code for Form :



Private Sub Command1_Click()
Unload Form3
End Sub



(D) Run the Project :

Select Details (From MDI Form ) then we can see the Datas in Grid Form as;



(E) Errors :

If found any errors while running your VB program, or want to put your comment about any  program , please click Comment section , to post

      • ====================================================================
        Back to Home   &  VB ===========================================================

No comments: