dcsimg
Results 1 to 8 of 8
  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    14

    Unhappy Datagrid connection with ADODB

    Hi there,

    I was wondering how I can connect a datagrid using a Adodb connection, if someone knows how please let me know.

    Thank you in advance...........

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Datagrid connection with ADODB

    Here is one method.

    VB Code:
    1. Private Sub Form_Load()
    2.     Dim db As ADODB.Connection
    3.     Dim rs As ADODB.Recordset
    4.    
    5.     Set db = New ADODB.Connection
    6.     db.Open "provider=sqloledb;data source=(local);integrated security=sspi"
    7.     db.DefaultDatabase = "Northwind"
    8.    
    9.     Set rs = New ADODB.Recordset
    10.     rs.CursorLocation = adUseClient
    11.     rs.Open "Select * From Customers", db, adOpenStatic, adLockReadOnly
    12.     Set rs.ActiveConnection = Nothing
    13.    
    14.     Set DataGrid1.DataSource = rs
    15.    
    16.     Set rs = Nothing
    17.     db.Close
    18.     Set db = Nothing
    19.  
    20. End Sub

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,812

    Re: Datagrid connection with ADODB

    Like many other members I don't use the DataGrid. What I tend to use is a FlexGrid, which can be easily filled from an ADODB connection - see the link in my signature for example code.

  4. #4
    New Member
    Join Date
    Jun 2006
    Posts
    8

    Re: Datagrid connection with ADODB

    Quote Originally Posted by si_the_geek
    Like many other members I don't use the DataGrid. What I tend to use is a FlexGrid, which can be easily filled from an ADODB connection - see the link in my signature for example code.
    hi geek,

    what is the real advantages and disadvantages of datagrid compared to flexgrid?

  5. #5

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    14

    Re: Datagrid connection with ADODB

    Hi,

    I was also wondering how I can add a drop-down list within a datagrid or flexgrid. This dropdown should be able to have values which can updated that current record.

    Any ideas..................

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,812

    Re: Datagrid connection with ADODB

    Here's one way... when a cell is entered, you could show a combobox (which was hidden until then) over the top of the cell. When a value is selected in the combobox, that value is copied to the cell, and the combobox is hidden again.

    Quote Originally Posted by DPSK
    what is the real advantages and disadvantages of datagrid compared to flexgrid?
    The big difference is that the DataGrid is bound (the data is filled automatically, and changes are written to the database), whereas the FlexGrid isn't (it needs to be filled using code, and does not update the database unless you write code to do that).

    Obviously whether or not this is a good or bad thing depends on the situation.

  7. #7

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    14

    Re: Datagrid connection with ADODB

    Hey Si,

    I've been trying out your possible solution and I really struggling, If you have coded something like this, please show me as its very important. I'll keep on trying. The problem I'm having is the combobox is not updating the field in the record.

    I look forward to hearing from you. Thanks..........

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    39,812

    Re: Datagrid connection with ADODB

    I have done it before, but I don't have the code available.. not that it would help anyway, as your project probably works in a different way to how mine did.

    If you post your form, we can suggest changes for you to make to get it working.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.