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 7831367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:41:47+00:00 2026-06-02T11:41:47+00:00

I am using PetaPoco.Core 4.0.3 in a C# app to access a MySql database.

  • 0

I am using PetaPoco.Core 4.0.3 in a C# app to access a MySql database.

I’m trying to create a query that uses variables, but I don’t want them to be treated by PetaPoco as input parameters. Here is a useless query just to show what I mean:

SET @num := 0;

SELECT
  @num := @num + 1 AS row_number
FROM
  buzz
LIMIT 100;

When I do that, PetaPoco recognizes @num as an input parameter and I receive the following error:

Parameter ‘@num’ specified but none of the passed arguments have a property with this >name (in ‘SET @num := 0; SELECT @num;’)

I also tried to escape the @ character by doubling it

SET @@num := 0;

SELECT
  @@num := @@num + 1 AS row_number
FROM
  buzz
LIMIT 100;

but then I receive

Parameter ‘@num’ must be defined.

Is there a way of declaring and using variables in a query without PetaPoco recognizing them as input parameters?

Thanks in advance

Paulo

  • 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-06-02T11:41:48+00:00Added an answer on June 2, 2026 at 11:41 am

    I found the solution. The problem was in the .NET connector settings (see http://blog.tjitjing.com/index.php/2009/05/mysqldatamysqlclientmysqlexception-parameter-id-must-be-defined.html)

    I had to change my connection string by adding the property “Allow User Variables” and setting it to true.

    Database=db;Data Source=localhost;User Id=root;Password=pass;Allow User Variables=True

    After that, the second version of my query (@@variable) started to work.

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

Sidebar

Related Questions

I need to create a DAL and repositories using petapoco. The difficulty that comes
Using top it's easy to identify processes that are hogging memory and cpu, but
I'm using PETAPOCO make a list of generic objects that are then bound to
I'm using C# with TSQL and SQL Server 2005 I'm trying to use PetaPoco
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
This is puzzling me. I'm using PetaPoco to retreive some values from a database,
Using Xcode4.2.1, with a basic PhoneGap template based app. (I say template, but I
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
I'm trying to setup an output parameter using PetaPoco. I found someone using this
I'm building a multi-tenant app with a shared database using .NET MVC 3 and

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.