locked
No column in TableAdapter RRS feed

  • Question

  • Hi all,

    I have having this SQL query. When I put the code into TableAdapter Configuration Wizard, the wizard did not detect any column nor @startdate and @enddate parameter. To resolve the @startdate and @enddate parameter issue, I manually add using Parameters Collection Editor. The question left is how I am able to make Sample_Value and Sample_TDate appear in the DataTable column. I need the column to generate chart in RDLC report.

    DECLARE @TempFrequency as table 
    (
       Sample_Value float,
       Sample_TDate datetime
    )
    
    DECLARE @TempSortFrequency as table 
    (
       RowIdFrequency int identity(1,1),
       Sample_Value float,
       Sample_TDate datetime
    )
    
    Declare @TempGoodFrequency as table
    (
    Sample_Value float,
    Sample_Tdate datetime
    )
    
    
    insert into @TempFrequency(Sample_Value, Sample_TDate)
    select Sample_Value, Sample_TDate
    from totesttable
    cross apply
    (select Sample_Value_1, Sample_TDate_1 union all
    select Sample_Value_2, Sample_TDate_2
    )
    d (Sample_Value, Sample_TDate)
    where Signal_Index = 4 and Sample_TDate is not null
    
    insert into @TempSortFrequency
    select Sample_Value, Sample_TDate from @TempFrequency
    
    ORDER BY CAST(CONVERT(varchar(10), Sample_TDate, 101) 
    + ' ' + CONVERT(varchar(8), Sample_TDate, 108) AS DATETIME)
    ASC 
    
    SELECT format(MAX(Sample_Value), '##.##') as Sample_value, DATEADD(minute, DATEDIFF(minute, 0, Sample_TDate) / 30 * 30, 0) as Sample_TDate FROM @TempSortFrequency AS tbl WHERE (Sample_TDate BETWEEN @startdate AND @enddate) GROUP BY DATEADD(minute, DATEDIFF(minute, 0, Sample_TDate) / 30 * 30, 0) ORDER BY Sample_TDate asc
    

    Monday, September 18, 2017 9:24 AM

Answers

  • Hi CF.Choong

    Thank you for posting the problem here.

    For TableAdapter, it just provides communication between your application and a database. They connect to the database, run queries or stored procedures, and either return a new data table or fill an existing DataTable with the returned data. TableAdapters can also send updated data from your application back to the database. But it doesn’t create a table by TableAdapter. If you would like to create and configure a TableAdapter, you could refer to the following link.

    https://msdn.microsoft.com/en-us/library/6sb6kb28.aspx?f=255&MSPPError=-2147217396

    For your code, I made a test which I got an error, as follows.

    For the usage of TablAdapter, it just can execute some select/update/insert/delete query statement.

    As the above picture shows, TableAdapter is used to connect and access a database.

    If  you would like to insert some data into your table, you could refer to the following gif picture.

    Attaching file

    Here is the result:

    If you would like to create a stored procedure, you could refer to the following.

    I'm glad to be of help to you.

    Best Regards,

    Bob


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by CF.Choong Tuesday, September 26, 2017 9:48 AM
    Thursday, September 21, 2017 6:32 AM