Results 1 to 4 of 4

Thread: Ammending code to show on data bound grid

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Resolved Ammending code to show on data bound grid

    Normally when i open an ado code i do it as the code is below.

    I would like to know how to ammend the code so it shows it in a databound grid???????????????

    I know it has something to do with datasource property but cannot work out the correct place to place it and what to call it with.
    I no longer want to show it in a textbox.

    VB Code:
    1. Private Sub Form_Load()
    2.     Set r = GetData
    3.     textbox1.text = r![InvoiceNo]
    4. End sub
    5.  
    6. Public Function GetData() As ADODB.Recordset
    7. On Error Resume Next
    8. Dim strsql As String
    9. Dim r As ADODB.Recordset
    10. Dim c As ADODB.Connection
    11.  
    12. Set c = New ADODB.Connection
    13. c.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False; Data Source=.\home.mdb;"
    14. c.Open
    15.  
    16. strsql = "SELECT * from Invoice"
    17. Set r = New ADODB.Recordset
    18. r.Open strsql, c, adOpenDynamic, adLockPessimistic
    19.  
    20. Set GetData = r
    21. End Function
    Last edited by snipered; Nov 21st, 2004 at 05:51 PM.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Just set the datasource to the recordset. I don't use bound mode but I think you need to use a Client Side cursor on the recordset.


    VB Code:
    1. Private Sub Form_Load()
    2.     Set DataGrid1.DataSource = GetData
    3. End sub
    Last edited by brucevde; Nov 21st, 2004 at 11:37 AM.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509
    Thanx for that, it didn't work with a data bound grid, kept bringing up errors so i tried it with a ms flex grid and it did the job.

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901
    you know, I was going to suggest that last night, but wanted to learn a bit more, so I waited for replies.

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