Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Table is not valid for dataset

Posted on 2004-10-05
4
Medium Priority
?
279 Views
Last Modified: 2008-03-10
I am currently manually filling a dataset and datagrid and it is working fine. On another form I have a VB.net filled datagrid.  I am trying to get the mouse event on the manually filled datagrid.

Here is mouse event for form1,  THIS WORKS,  THE DataSET  is created from vb.net wizard

    Private Sub datagridClick(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles DataGrid.MouseDown
        Dim mouseClick As DataGrid.HitTestInfo
        Dim descIndex As Integer
        Dim picIndex As Integer

        If e.Button = MouseButtons.Left Then

            dgObservation = CType(sender, DataGrid)
            mouseClick = DataGrid.HitTest(e.X, e.Y)
            gridRow = mouseClick.Row

            'Get variable of selected rows

            On Error Resume Next
            PnIndex = Me.DbDataSet.T_PARTS.Columns.IndexOf("TRDB_PN")
            Pnname = Me.DbDataSet.T_PARTS.Rows(gridRow)(PnIndex).ToString

-------------------------------------------------------------------------------------------------------------------------------------
This is the manually created one on form 2

It fills the dataset correctly.

    Dim sConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & DBNAME & ";Persist Security Info=False"

        Dim sSQL1 As String = "SELECT DISTINCT T_RESOURCES.RESOURCE_ID, T_RESOURCES.RESOURCE_TITLE, T_RESOURCES." & _ "RESOURCE_LINK_VIEW, T_RESOURCES_GRP_XREF.GRP_ID, T_RESOURCES_GRP_XREF.SUB_GRP_ID" & _       ", T_RESOURCES_GRP_XREF.XREF_SOURCE FROM (T_RESOURCES INNER JOIN T_RESOURCES_GRP_" & _
        "XREF ON T_RESOURCES.RESOURCE_ID = T_RESOURCES_GRP_XREF.RESOURCE_ID) WHERE (T_RESOURCES_GRP_XREF.GRP_ID = '" & libstring & "')"

        oleDA1 = New OleDbDataAdapter(sSQL1, sConn)
        oleDA1.Fill(manset)

 Dim tsm
        Me.ManDataGrid.DataSource = manset
        Me.ManDataGrid.DataMember = "Table"

        tsm = New DataGridTableStyle
        tsm.mappingname = "Table"

        ' Create columns
        Dim DataColParent As New DataGridTextBoxColumn
        DataColParent.HeaderText = "RESOURCE"
        DataColParent.MappingName = "RESOURCE_ID"
        'DataColParent.NullText = "NO PARTS"
        DataColParent.Width = 89
        tsm.GridColumnStyles.Add(DataColParent)

------------------ This is where the error comes that I cannot compile

 Private Sub datagridClick(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles ManDataGrid.MouseDown
        Dim mouseClick As DataGrid.HitTestInfo
        Dim descIndex As Integer
        Dim picIndex As Integer

        If e.Button = MouseButtons.Left Then

            dgObservation = CType(sender, DataGrid)
            mouseClick = ManDataGrid.HitTest(e.X, e.Y)
            gridrow = mouseClick.Row

                                VVVV----------------------------------------Table is not a member of System.Data.Dataset
IDIndex = Me.manset.Table.Columns.IndexOf("Resouce_ID")
ID = Me.manset.m.Rows(gridrow)(IDIndex).ToString

                                         

I think it is just mapping Table as the table for manset, or binding the name to it,   I am lost

Thanks, Malanois
0
Comment
Question by:malanois
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 6

Expert Comment

by:PreachDotNet
ID: 12227845
try me.manset.tables(0).columns ... etc
0
 
LVL 16

Expert Comment

by:RobertRFreeman
ID: 12228310
Or me.manset.tables("Table").columns.IndexOf("Resource_ID")

The problem with your code is that you are not using a strongly typed generated dataset, therefore you cannot reference the dataset table via the property (.Table).  You could do the same by manually adding a Dataset (xsd) to your project and declaring manset as the custom dataset.  Or using the one generated in the form.
0
 
LVL 16

Expert Comment

by:RobertRFreeman
ID: 12228361
Oh yeah and you can skip the index part as follows:

IDIndex = Me.manset.Table.Columns.IndexOf("Resouce_ID")
ID = Me.manset.m.Rows(gridrow)(IDIndex).ToString

would be:

ID = Me.manset.m.Rows(gridrow)("Resource_ID").ToString


Note: You can look in the Windows Generated Code section to see how the wizard generated code works.
0
 
LVL 16

Accepted Solution

by:
RobertRFreeman earned 2000 total points
ID: 12228394
sorry,

ID = Me.manset.m.Rows(gridrow)("Resource_ID").ToString

should be

ID = Me.manset.tables(0).Rows(gridrow)("Resource_ID").ToString
or
ID = Me.manset.tables("Table").Rows(gridrow)("Resource_ID").ToString

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question