#5 ParameterMarker problem

Ulf Werner


I'm using MPM 1.2.1 against MSSQLServer and using the
filter ParameterMarkers. My application is written in
ODBC style with '?' as parameter markers. If I try to use
the Sql plugin I get the exception
System.Data.SqlClient.SqlException: Must declare the
variable '@p'.

I attach a textfile with the complete errormessage.

Ulf Werner


  • Fredrik Ĺlund

    Fredrik Ĺlund - 2004-04-15
    • assigned_to: nobody --> mimerbg
  • Bengt Gunne

    Bengt Gunne - 2004-04-15

    Logged In: YES

    The parameter marker filter generated parameter markers
    with names p%d instead of p1, p2 and so on. Sql Server
    ignores %d (for som reason) and asks for a parameter named

    A correction has been committed to CVS. For your application
    to work you may have to review the parameter marker names
    used in calls to MpmParameter. These should be set to p1,
    p2, p3 and so on in order to cooperate with the Sql Filter.

    Please let me know if it works for you!

    I am investigating whether parameters without the name set
    can automatically adopt the p1,p2, p3 convention.

  • Bengt Gunne

    Bengt Gunne - 2004-04-15
    • status: open --> pending
  • Bengt Gunne

    Bengt Gunne - 2004-04-16

    Logged In: YES

    It is now possible to let Mpm do the parameter naming:

    MpmParameter par1 = new MpmParameter();
    par1.MpmType = MpmType.Int;
    par1.Value = 10;
    MpmParameter par2 = new MpmParameter();
    par2.MpmType = MpmType.Int;
    par2.Value = 10;
    MpmCommand cmd = new MpmCommand("insert into t values
    (?,?)", conn);
    // Par1 will now be called "p1"
    // Par2 will now be called "p2"

    The above logic allows, for example, Sql Server to be used
    which wants matching parameter names in both SQL
    statement and parameters. Note that the ParameterMarkers
    SQL Filter must be used.

  • Ulf Werner

    Ulf Werner - 2004-04-23
    • status: pending --> open-works-for-me
  • Ulf Werner

    Ulf Werner - 2004-04-23

    Logged In: YES

    Now it works!

    Thanks again

  • Bengt Gunne

    Bengt Gunne - 2004-04-23
    • status: open-works-for-me --> closed-works-for-me

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks