Results 1 to 2 of 2

Thread: vb and Ms Access

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    7

    vb and Ms Access

    1.how can i use gride in visual basic 6.0 using database access
    2. how can i search the data in gride using textbox
    3. how can i update,save,delete records in vb using query

  2. #2
    Lively Member preethi_rjs's Avatar
    Join Date
    Dec 2006
    Posts
    80

    Re: vb and Ms Access

    include Grid in ur form from Project->Components.

    to display the data from database to Grid use following codings:

    VB Code:
    1. With MSFlexGrid1
    2.     .Rows = 1
    3.     .Rows = 2
    4.           i = .Row
    5.     Set rview = d.Execute("select * from table1")
    6.     MSFlexGrid1.Sort = 1
    7.     Do While Not rview.EOF
    8.         .TextMatrix(i, 0) = rview!field1
    9.         .TextMatrix(i, 1) = rview!field2
    10.         .TextMatrix(i, 2) = rview!field3
    11.         rview.MoveNext
    12.         .Rows = .Rows + 1
    13.         i = i + 1
    14.     Loop
    15. End With


    To add, delete and update records.........first open connection using following codings:

    VB Code:
    1. conn.Close
    2. conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\db1.mdb;Persist Security Info=False"
    3. conn.Open

    then normal SQL stmts are used to do required functions. for example:

    VB Code:
    1. Set rsave = d.Execute("insert into table1 values('" + Text1 + "','" + Text2 + "','" + Text3 + "','" + Text4 + "')")
    Preethi.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width