May anyone explain me how to use DBGrid in VB6.0 ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sreekandan
    New Member
    • Nov 2006
    • 98

    May anyone explain me how to use DBGrid in VB6.0 ?

    Now I have to use DBGrid to edit and retrieve from the database.
    So how can I do that in VB6.0?.So kindly reply me anyone quickly.
  • vijaydiwakar
    Contributor
    • Feb 2007
    • 579

    #2
    Originally posted by sreekandan
    Now I have to use DBGrid to edit and retrieve from the database.
    So how can I do that in VB6.0?.So kindly reply me anyone quickly.
    Code:
    Private Sub Command1_Click()
    
    rs0.opend "select * from table ", Conn
    db.DataSource = rs0
    End Sub
    in this way u can retrive the data

    Comment

    • sreekandan
      New Member
      • Nov 2006
      • 98

      #3
      Originally posted by vijaydiwakar
      Code:
      Private Sub Command1_Click()
      
      rs0.opend "select * from table ", Conn
      db.DataSource = rs0
      End Sub
      in this way u can retrive the data
      I couldn't access with that code. So I want the codings with some more details.

      Comment

      • vijaydiwakar
        Contributor
        • Feb 2007
        • 579

        #4
        Originally posted by sreekandan
        I couldn't access with that code. So I want the codings with some more details.
        explain me thy reqd in detail

        Comment

        • sreekandan
          New Member
          • Nov 2006
          • 98

          #5
          Originally posted by vijaydiwakar
          explain me thy reqd in detail
          I want to retrieve the database fields in DBGrid .
          My database table is table1,The fields are empid,dat....
          For that kidly send me the codings to show/edit the databse contents in DBGrid1.

          Comment

          • vijaydiwakar
            Contributor
            • Feb 2007
            • 579

            #6
            Originally posted by sreekandan
            I want to retrieve the database fields in DBGrid .
            My database table is table1,The fields are empid,dat....
            For that kidly send me the codings to show/edit the databse contents in DBGrid1.
            Code:
             
            dim Rs0 as new Adodb.Recordset
            dim Conn as new Adodb.Connection
            Conn.open " Connection String"
            ssql="select * from table1"
            rs0.open ssql,Conn
            with grd
            
            do while rs0.eof=false
            .rows=.rows+1
            .textmatrix(.rows,1)=rs0("fiildname") &""
            .textmatrix(.rows,2)=rs0("fiildname") &""
            rs0.movenext
            loop
            rs0.close:set rs0=nothing
            end with
            in this way u can retrive d data

            Comment

            • sreekandan
              New Member
              • Nov 2006
              • 98

              #7
              Originally posted by vijaydiwakar
              Code:
               
              dim Rs0 as new Adodb.Recordset
              dim Conn as new Adodb.Connection
              Conn.open " Connection String"
              ssql="select * from table1"
              rs0.open ssql,Conn
              with grd
              
              do while rs0.eof=false
              .rows=.rows+1
              .textmatrix(.rows,1)=rs0("fiildname") &""
              .textmatrix(.rows,2)=rs0("fiildname") &""
              rs0.movenext
              loop
              rs0.close:set rs0=nothing
              end with
              in this way u can retrive d data

              I tried with that code.But the error occured as "Object required"

              Comment

              • vijaydiwakar
                Contributor
                • Feb 2007
                • 579

                #8
                Originally posted by sreekandan
                I tried with that code.But the error occured as "Object required"
                for that first of all add control of grid and rename it to the name of grid which ihave given in 'with' code

                Comment

                • sreekandan
                  New Member
                  • Nov 2006
                  • 98

                  #9
                  Originally posted by vijaydiwakar
                  for that first of all add control of grid and rename it to the name of grid which ihave given in 'with' code
                  Can you explain me the following code from you have given
                  Code:
                  .rows=.rows+1
                  .textmatrix(.rows,1)=rs0("fiildname") &""
                  .textmatrix(.rows,2)=rs0("fiildname") &""

                  Comment

                  • vijaydiwakar
                    Contributor
                    • Feb 2007
                    • 579

                    #10
                    Originally posted by sreekandan
                    Can you explain me the following code from you have given
                    Code:
                    .rows=.rows+1
                    .textmatrix(.rows,1)=rs0("fiildname") &""
                    .textmatrix(.rows,2)=rs0("fiildname") &""
                    line 1 increments grid row by one
                    2 assigns recordset's field data to perticular cell with last newest row and 1,2 column

                    Comment

                    Working...