dcsimg


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: db grid help!

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    db grid help!

    [Originally posted by nykhol]

    is it possible to add, edit, or delete a specific record from your dbase using the dbgrid?
    i mean entering data directly on the dbgrid.
    i'm using access as my back-end.
    can i have the code please?tnx.

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re: db grid help!

    [Originally posted by Daniel Simpson-Dernovoy]

    Hi Nykhol,

    the main purpose of the DB Grid for your user is to be able to add, edit and delete records in your database.

    The "datasource" property of your datagrid should be a "datacontrol"

    **
    datacontrol1.database = [ACCESSDATABASE_FULLPATH]
    e.g. datagrid1.datasource = Datacontrol1


    datacontrol1.recordsource = [NAME OF TABLE YOU ARE CONNECTING TO OR STANDARD SQL STRING]

    datacontrol1.refresh
    datagrid1.rebind

    **

    This will connect the datacontrol to your access database and then bind the datagrid to your datacontrol.

    Ensure that the "AllowAddNew", "AllowDelete", "AllowUpdate" properties of the grid are set to True and this will allow full editing of data for your user.


  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re: db grid help!

    [Originally posted by nykhol]

    datacontrol1.database = [ACCESSDATABASE_FULLPATH]
    e.g. datagrid1.datasource = Datacontrol1

    ---------can you give me a more further example of this coz i can't get how to put it as a datacontrol,,where should i look for the datacontrol1?......sorry,still need help!tnx!

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re: db grid help!

    [Originally posted by Daniel Simpson-Dernovoy]

    Hi,

    DAO data control can be found from VB standard controls and dragged and used on a form. The default control name would be "Data1". If you
    rename it as "datacontrol1" the code I gave you would work (remember to put in the full name of your access path !

    good luck,

    Dan.

  5. #5
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Re: db grid help!

    [Originally posted by nykhol]

    ah ic !tnx but
    An error occurred:
    Unrecognized database format!
    then it says "External name not defined"

    can you check dis one out?
    Private Sub DBGrid1_GotFocus()
    Data1.Database=[C:\WINDOWS\Desktop\generic\db1.mdb]
    DBGrid1.DataSource = Data1


    Data1.RecordSource = "Select lCust_Info.Cust_Name,
    tblInvoice.Inv_No From tblInvoice,tblCust_Info"

    Data1.Refresh
    DBGrid1.ReBind


    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center