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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:06:21+00:00 2026-06-09T05:06:21+00:00

I got a problem using dapper to attach parameters to my MySql queries. Now

  • 0

I got a problem using dapper to attach parameters to my MySql queries.
Now this may be a noobish problem, but I’ve beaten my head on this for the better part of 2 hours now and it’s still not working.

My problem is with the SelectWithParametersTest() function right in the middle. Here is what I’ve got…

EDIT: Ok more details.
The actual Mysql server throws fits and says, “ERROR [07001] [MySQL][ODBC 3.51 Driver][mysqld-5.1.61-0ubuntu0.11.10.1-log]SQLBindParameter not used for all parameters”.

The actual exception gets caught at QueryInternal<T>(…) on the line where it’s executing the reader. (using(var reader = cmd.ExecuteReader())

When I inspect the command there are no parameters attached to it, but the param object (that was passed to the function) has my anon object in it.

using System;
using System.Data;
using System.Collections.Generic;
using Dapper;

class Program
{
    static void Main(string[] args)
    {
        using (var dapperExample = new DapperExample())
        {
            //dapperExample.SelectTest();
            dapperExample.SelectWithParametersTest();
        }
    }
}

class DapperExample : IDisposable
{
    #region Fields
    IDbConnection _databaseConnection;
    #endregion

    #region Constructor / Destructor
    public DapperExample()
    {
        _databaseConnection = new System.Data.Odbc.OdbcConnection("DSN=MySqlServer;");
        _databaseConnection.Open();
    }

    public void Dispose()
    {
        if (_databaseConnection != null)
            _databaseConnection.Dispose();
    }
    #endregion

    #region Public Methods (Tests)
    public void SelectTest()
    {
        // This function correctly grabs and prints data.
        string normalSQL = @"SELECT County as CountyNo, CompanyName, Address1, Address2
                             FROM testdb.business
                             WHERE CountyNo = 50 LIMIT 3";

        var result = _databaseConnection.Query<ModelCitizen>(normalSQL);
        this.PrintCitizens(result);
    }

    public void SelectWithParametersTest()
    {
        // This function throws OdbcException: "ERROR [07001] [MySQL][ODBC 3.51 Driver][mysqld-5.1.61-0ubuntu0.11.10.1-log]SQLBindParameter not used for all parameters"
        string parameterizedSQL = @"SELECT County as CountyNo, CompanyName, Address1, Address2
                                    FROM testdb.business
                                    WHERE CountyNo = ?B";
        var result = _databaseConnection.Query<ModelCitizen>(parameterizedSQL, new { B = 50 });
        this.PrintCitizens(result);
    }
    #endregion

    #region Private Methods
    private void PrintCitizens(IEnumerable<ModelCitizen> citizenCollection)
    {
        foreach (var mc in citizenCollection)
        {
            Console.WriteLine("--------");
            Console.WriteLine(mc.BankNo.ToString() + " - " + mc.CompNo.ToString());
            Console.WriteLine(mc.CompanyName);
            Console.WriteLine(mc.Address1);
            Console.WriteLine(mc.Address2);
        }
        Console.ReadKey();
    }
    #endregion
}

public class ModelCitizen
{
    public long CountyNo { get; set; }
    public string CompanyName { get; set; }
    public string Address1 { get; set; }
    public string Address2 { get; set; }
}
  • 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-09T05:06:22+00:00Added an answer on June 9, 2026 at 5:06 am

    Yokin, did you try using a UInt32 instead of long in the C# code?

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

Sidebar

Related Questions

So I'm using Django to build a webservice, but I've got a problem with
I've got this strange problem using py-amqp and the Flopsy module. I have written
i'm doing some code now and got some problem using restrict keyword. typedef int*
I've got this problem using jQuery's .each() function. I want to sort the rows
I've got a problem using different layouts for list items in my project. Here
i got a strange Problem using Jain Sip (dowload today Version Jain-sip-ri-1.2.2014.jar). I'm connecting
I've got a little problem using WPF Dispatcher Timer. On each timer tick my
I got a probably small problem using memcmp. I have two arrays (length =
I got problem with sending data in Android using httpPost. I found some example,
Got a problem with ComponentListener. I'm using it to check if a certain component

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.