Results 1 to 9 of 9

Thread: [RESOLVED] Syntax error with Table Adapter

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Resolved [RESOLVED] Syntax error with Table Adapter

    I have been working on doing some reports with a Parameter entered prior to printing I seem to be narrowing the problem But I now have another one that I need help with,
    Code:
    Imports Microsoft.Reporting.WinForms
    
    Public Class WorkOrderClose
        Private Sub WorkOrderClose_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'HiTechDataSet7.WorkOrders' table. You can move, or remove it, as needed.
            Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet7.WorkOrders)
            Dim newPageSettings As New System.Drawing.Printing.PageSettings
            newPageSettings.Margins = New System.Drawing.Printing.Margins(35, 35, 35, 35)
            ReportViewer1.SetPageSettings(newPageSettings)
    
            'TODO: This line of code loads data into the 'HiTechDataSet.WorkOrders' table. You can move, or remove it, as needed.
            'Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet.WorkOrders)
    
            'Me.ReportViewer1.RefreshReport()
    
        End Sub
    
        Private Sub txtPrint_Click(sender As Object, e As EventArgs) Handles txtPrint.Click
            Dim WOID As New ReportParameter
            WOID.Name = "WOID"
            WOID.Values.Add(txtBoxWO.Text)
    
            Try
                Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet7.WorkOrders)
                ReportViewer1.LocalReport.SetParameters(New ReportParameter() {WOID})
                Me.ReportViewer1.RefreshReport()
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try
        End Sub
    End Class
    In the Workorder close sub
    LINE" Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet7.WorkOrders)"

    the command work Fill is in error. same for the line Sub txyPrint_Click
    " Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet7.WorkOrders)"

    Unsure how to fix these, I believe I may have the other errors fixed from my last posts

    Thanks for your support

  2. #2
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Syntax error with Table Adapter

    What is the error?

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Syntax error with Table Adapter

    Sorry here is the error description:


    Severity Code Description Project File Line Suppression State
    Error BC30455 Argument not specified for parameter 'WOID' of 'Public Overridable Overloads Function Fill(dataTable As HiTechDataSet7.WorkOrdersDataTable, WOID As Integer) As Integer'. HiTech3 C:\Users\HITECHDEV\Documents\Visual Studio 2017\Projects\HiTech3\HiTech3\WorkOrderClose.vb 6 Active

  4. #4
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,206

    Re: Syntax error with Table Adapter

    It sounds like the Fill query is expecting a parameter, like

    Code:
    Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet7.WorkOrders, yourParameterHere)

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Syntax error with Table Adapter

    oK I MADE THIS CHANGE AND NOW HAVE THIS ERROR
    Code:
    System.InvalidCastException
      HResult=0x80004002
      Message=Conversion from string "WOID" to type 'Integer' is not valid.
      Source=Microsoft.VisualBasic
      StackTrace:
       at Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String Value)
       at HiTech3.WorkOrderClose.WorkOrderClose_Load(Object sender, EventArgs e) in C:\Users\HITECHDEV\Documents\Visual Studio 2017\Projects\HiTech3\HiTech3\WorkOrderClose.vb:line 6
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    
    Inner Exception 1:
    FormatException: Input string was not in a correct format.
    CHANGES MADE
    Code:
     Me.WorkOrdersTableAdapter.Fill(Me.HiTechDataSet7.WorkOrders, "WOID")
    TRIED VARIOUS TEXT SYNTAXES BUT NO CHANG OR GIVES ERROR OF EXPECTED MISSING

    NOT SURE WHAT TO DO NOW.

    THANKS

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Syntax error with Table Adapter

    How do you not even know how your own queries work? That Fill method is not expecting you to pass the text "WOID". What use would that be? It's expecting you to provide a WOID value, i.e. an ID for a WorkOrder record to use as a filter in the query. If your query has a WHERE clause that filters by the WOID column, how else do you expect that filter value to get in there?

    That said, you really ought not to have filters on your default query. It's not "wrong" per se but, generally speaking, the Fill method should execute a default query that has no filters and then, if you want to be able to filter, you add extra queries to your table adapter with appropriate filters and map them to extra methods. If you want to be able to filter by WOID then you add an extra query with the appropriate WHERE clause and then name the associated methods FillByWOID and GetDataByWOID.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Syntax error with Table Adapter

    sO I HAVE BEEN FIGHTING THIS FOR 5 DAYS. I HAVE FOUND MORE ISSUES THAN I CARE TO THINK ABOUT. BUT APPARTENTLY VISUAL STUDIO HAS AN ISSUE WITH REPORTS AND A FILLBY ADAPTER. FIRST MY LIST OF DATA SOURCES DISAPPERED ACCORDING TO THE REPAIRS AVAILABLE THEY SAID IT WAS BEST NOT TO USE A FILLBY. SO I DELETED ALL AND RESTARTED BY ADDING THE WHERE STATEMANT TO THE FILL ADAPTER. THE QUERRY RAN OK FROM THE TST AREA. BUT THEN ADDITIONAL ERRORS SHOWED UP. NOW I HAVE THIS ERROR

    Code:
    Deserialization failed: The element 'Report' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' has invalid child element 'ReportSections' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'. List of possible elements expected: 'Description, Author, AutoRefresh, DataSources, DataSets, Body, ReportParameters, Code, Width, Page, EmbeddedImages, Language, CodeModules, Classes, CustomProperties, Variables, DeferVariableEvaluation, ConsumeContainerWhitespace, DataTransform, DataSchema, DataElementName, DataElementStyle' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' as well as any element in namespace '##other'. Line 107, position 4.
    HONESTLY I'm AT A LOST NOW

    THANKS

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2006
    Posts
    320

    Re: Syntax error with Table Adapter

    HEE IS THE CODEIN XML STARTING LINE 97 THRU 126
    Code:
    Deserialization failed: The element 'Report' in namespace
     'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' has invalid child element 'ReportSections' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'. List of possible elements expected: 'Description, 
    Author, AutoRefresh, DataSources, DataSets, Body, ReportParameters, Code, Width, Page, EmbeddedImages, Language, CodeModules,
     Classes, CustomProperties, Variables, DeferVariableEvaluation, ConsumeContainerWhitespace, DataTransform, DataSchema, 
    DataElementName, DataElementStyle' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'
     as well as any element in namespace '##other'. Line 107, position 4.
    eRROR WAS
    Code:
    Deserialization failed: The element 'Report' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' has invalid child element 'ReportSections' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition'. List of possible elements expected: 'Description, Author, AutoRefresh, DataSources, DataSets, Body, ReportParameters, Code, Width, Page, EmbeddedImages, Language, CodeModules, Classes, CustomProperties, Variables, DeferVariableEvaluation, ConsumeContainerWhitespace, DataTransform, DataSchema, DataElementName, DataElementStyle' in namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' as well as any element in namespace '##other'. Line 107, position 4.

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Syntax error with Table Adapter

    The title of this thread says:
    Syntax error with Table Adapter
    It seems like we're well out of that territory. If that issue is resolved then you should use the Thread Tools menu to mark this thread Resolved. If you have another issue then you should start a new thread with a title that describes that issue and a post that contains all the information relevant to that issue and only that issue.

    I'm not sure what you read but table adapters have nothing to do with reports. The data source for your report will be a DataTable within your DataSet. The report will show whatever that DataTable contains. The table adapter is simply a means to get data into that DataTable. Whether you use Fill or FillByWOID is irrelevant to the report. You could even populate the DataTable manually from a text file if you wanted. The report doesn't care how the data got there.

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