Results 1 to 2 of 2

Thread: Populating Datagrid

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2004
    Posts
    11

    Populating Datagrid

    I'm trying to populate a datagrid and am getting an error.

    VB Code:
    1. Dim dg As DataGrid
    2.         Dim cn As ADODB.Connection
    3.         Dim rs As ADODB.Recordset
    4.         Dim strConnect As String
    5.  
    6.         dg = New DataGrid()
    7.         rs = New ADODB.Recordset()
    8.  
    9.         strConnect = "DSN=Rebates;UID=;PWD="
    10.         cn = New ADODB.Connection()
    11.  
    12.         cn.Open(strConnect)
    13.         cn.CursorLocation = ADODB.CursorLocationEnum.adUseClient
    14.         rs = New ADODB.Recordset()
    15.         rs.Open("tempchecktable", cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic, ADODB.CommandTypeEnum.adCmdTable)
    16.  
    17.  
    18.         dg.DataSource = rs
    19.         dg.Refresh()
    20.  
    21.  
    22.         rs.Close()
    23.         cn.Close()

    The error I'm getting is...

    An unhandled exception of type 'System.Exception' occurred in system.windows.forms.dll

    Additional information: Complex DataBinding accepts as a data source either an IList or an IListSource

    Any suggestions

    thanks.

  2. #2
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950
    I've never seen a datagrid dimmed that way, and not sure you can use an ADODB recordset.
    Normally you'd drop a datagrid on your form from the toolbox, and populate it with a table in a dataset, or a dataview, etc.

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