Results 1 to 2 of 2

Thread: datagrid problem

  1. #1

    Thread Starter
    Frenzied Member vbdotnetboy's Avatar
    Join Date
    Jun 2004
    Location
    Lewisburg, PA "Next year Raiders in the Super Bowl"
    Posts
    1,310

    Question datagrid problem

    I keep getting an error when trying to populate my datagrid. everytime it hits the line for the mapping name it throws a null reference exception??? what am i doing wrong?

    VB Code:
    1. Try
    2.             Dim ds As New Data.DataSet
    3.  
    4.             Dim da As New OleDb.OleDbDataAdapter("select * from library_tbl", cn)
    5.  
    6.             da.Fill(ds)
    7.             Me.DataGrid1.DataSource = ds
    8.             With Me.DataGrid1.TableStyles
    9.                 With .Item("dgtsLibId")
    10.                     .MappingName = "library_tbl"
    11.                 End With
    12.             End With
    13.  
    14.         Catch ex As Exception
    15.             MessageBox.Show(ex.ToString)
    16.         End Try
    Last edited by vbdotnetboy; Mar 3rd, 2005 at 01:26 PM.

    Derek - Using VS 2008 99% of the time and VS 2003 1% of the time

    Please Help Us To Save Ana

    ● Helpful Links: DNR TV | Awesome site for tips | Using ADO.NET to work with Excel | Xml Namespace 2.0 Framework Changes|Ultra High Security Password Generator | Mendhak's ADO.NET Tutorial
    ● Code Bank: Random Password Generator | Generic DbProviderFactory Access
    ● Site Work: Bottle Run Xtreme | Spaids Racing.com

    Company I work for - CSSI

    WHEN POSTING PLEASE INDICATE VERSION

    Please use vbcode tags or code tags when posting code
    [highlight=vb]ALL your code goes here[/highlight] or [code]ALL your code goes here[/code]

    If my post helped you in anyway... please be kind and give me some ratings

  2. #2
    Lively Member
    Join Date
    Dec 2004
    Posts
    121

    Re: datagrid problem

    Try this:

    VB Code:
    1. Try
    2.         Dim ds As New Data.DataSet
    3.  
    4.         Dim da As New OleDb.OleDbDataAdapter("select * from library_tbl", cn)
    5.  
    6.         da.Fill(ds)
    7.         Me.DataGrid1.DataSource = ds
    8.  
    9.         With Me.DataGrid1.TableStyles
    10.             [B]Dim tableStyle1 As New DataGridTableStyle[/B]
    11.             With .Item("dgtsLibId")
    12.                 [B]tableStyle1[/b].MappingName = "library_tbl"
    13.             End With
    14.         End With
    15.  
    16.     Catch ex As Exception
    17.         MessageBox.Show(ex.ToString)
    18.     End Try

    My changes are in bold. It worked on my machine.

    One other thing to note: I believe MappingName is case sensitive.

    Good luck!

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