Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7623083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:37:00+00:00 2026-05-31T04:37:00+00:00

I am very confused with the error my SQL server is returning – what

  • 0

I am very confused with the error my SQL server is returning – what would be causing this?

The C# code I am running is :

List<CalendarEvent> events = new List<CalendarEvent>();
        var db = Database.Open("myDatabase");
        string username = HttpContext.Current.Request.Cookies.Get("username").Value;
        var listOfGroups = db.Query("SELECT GroupID FROM Membership WHERE UserID = (SELECT UserID from Users WHERE Username = @0 )",  username);

        foreach(var groupID in listOfGroups)
            {
                var result = db.Query(
                    @"SELECT e.event_id, e.title, e.description, e.event_start, e.event_end, e.group_id, e.recurring
                    FROM   event e
                    JOIN   Membership m ON m.GroupID = e.group_id
                    WHERE  e.recurring = 0
                    AND    m.GroupID = @0
                    AND    e.event_start >= @1
                    AND    e.event_end <= @2
                    UNION ALL
                    SELECT e.event_id, e.title, e.description, DATEADD(week, w.weeks, e.event_start), DATEADD(week, w.weeks, e.event_end), e.group_id, e.recurring
                    FROM   event e
                JOIN   Membership m ON m.GroupID = e.group_id
                CROSS JOIN 
                    ( SELECT  row_number() OVER (ORDER BY Object_ID) AS weeks
                    FROM SYS.OBJECTS
                    ) AS w
                    WHERE  e.recurring = 1
                    AND    m.GroupID = $3
                    AND    e.event_start >= @4
                    AND    e.event_end <= @5", groupID, start, end, groupID, start, end
                );
                foreach(var record in result)
                    {
                            CalendarEvent cevent = new CalendarEvent();
                            cevent.id = record.event_id;
                            cevent.title = record.title;
                            cevent.description = record.description;
                            cevent.start = record.event_start;
                            cevent.end = record.event_end;
                            cevent.recurring = record.recurring;
                            events.Add(cevent);
                    }
            }
        return events;
}

And the error:

Exception Details: System.ArgumentException: No mapping exists from
object type WebMatrix.Data.DynamicRecord to a known managed provider
native type.

What could be causing this and how can I fix it ?

What I wish to do is return all events where recurring = 0, and any events where recurring =1 I want to be returned for their week and the 52 weeks thereafter.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:37:01+00:00Added an answer on May 31, 2026 at 4:37 am

    Looks like your issue is with your groupID input parameter.

    var listOfGroups = db.Query("SELECT GroupID FROM Membership WHERE UserID = (SELECT UserID from Users WHERE Username = @0 )",  username);
    

    Your listOfGroups is coming back as a collection of the WebMatrix.Data.DynamicRecord objects. You seem to want just the int value, as you get groupID in the foreach(var groupID in listOfGroups) statement.

    Try instead replacing the last line:

    AND    e.event_end <= @5", groupID, start, end, groupID, start, end
    

    with:

    AND    e.event_end <= @5", (int)groupID.GroupID, start, end, (int)groupID.GroupID, start, end
    

    This should pull the value from the first (and only) column of each dynamic query result, that value being the int group ID that you are after.

    EDIT: Corrected value call syntax of DynamicRecord query result.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very confused with this error, it shows when I try to return a
Getting this error building a C++ project in VS2008. Very confused what it means,
I'm very confused about this error message, I'm completely unaware of any missing controllers
Very confused about this one. This code in views.py works, but only when I'm
I'm very confused by a compiler error. My code was thoroughly working 4-5 h
I am very confused. I have this lambda expression: tvPatientPrecriptionsEntities.Sort((p1, p2) => p1.MedicationStartDate .Value
I'm very confused on how this is supposed to work. I've tried using something
Very confused here, trying out the yuicompressor on a simple javascript file. My js
I'm very confused by the MSDN samples. And all the samples I find generally
I'm very confused about the whole user profile thing in drupal, hope someone can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.