Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. debug sql with parameters

debug sql with parameters

Scheduled Pinned Locked Moved C#
questiondatabasesysadmindebugging
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jogisarge
    wrote on last edited by
    #1

    Hi, i use VS2008 and SQLServer 2005. How can i debug a sql-statement, that includes parameters like this ?

    string sqlstatement = "INSERT INTO artikel (nr,text1,text2)" +
    "VALUES" +
    "( @parm1, " +
    " @parm2, " +
    " @parm3 " +
    " " +
    " )";
    SqlCommand sqlins = new SqlCommand(sqlstatement, con);
    sqlins.Parameters.Add("@parm1", SqlDbType.NVarChar).Value = var1;
    sqlins.Parameters.Add("@parm2", SqlDbType.Int).Value = var2;
    sqlins.Parameters.Add("@parm3", SqlDbType.Int).Value = var3;
    sqlins.ExecuteNonQuery();

    so, how can i see the statement, that will be sent to the sql-server ? bye jogi

    R D 2 Replies Last reply
    0
    • J jogisarge

      Hi, i use VS2008 and SQLServer 2005. How can i debug a sql-statement, that includes parameters like this ?

      string sqlstatement = "INSERT INTO artikel (nr,text1,text2)" +
      "VALUES" +
      "( @parm1, " +
      " @parm2, " +
      " @parm3 " +
      " " +
      " )";
      SqlCommand sqlins = new SqlCommand(sqlstatement, con);
      sqlins.Parameters.Add("@parm1", SqlDbType.NVarChar).Value = var1;
      sqlins.Parameters.Add("@parm2", SqlDbType.Int).Value = var2;
      sqlins.Parameters.Add("@parm3", SqlDbType.Int).Value = var3;
      sqlins.ExecuteNonQuery();

      so, how can i see the statement, that will be sent to the sql-server ? bye jogi

      R Offline
      R Offline
      Rob Philpott
      wrote on last edited by
      #2

      The parameters don't get substitued and then sent to SQL Server. Your statement gets sent and the parameters supplied seperately, SQL server then does the 'substitution'. It allows it to work more efficiently that way. So, not sure you can.

      Regards, Rob Philpott.

      1 Reply Last reply
      0
      • J jogisarge

        Hi, i use VS2008 and SQLServer 2005. How can i debug a sql-statement, that includes parameters like this ?

        string sqlstatement = "INSERT INTO artikel (nr,text1,text2)" +
        "VALUES" +
        "( @parm1, " +
        " @parm2, " +
        " @parm3 " +
        " " +
        " )";
        SqlCommand sqlins = new SqlCommand(sqlstatement, con);
        sqlins.Parameters.Add("@parm1", SqlDbType.NVarChar).Value = var1;
        sqlins.Parameters.Add("@parm2", SqlDbType.Int).Value = var2;
        sqlins.Parameters.Add("@parm3", SqlDbType.Int).Value = var3;
        sqlins.ExecuteNonQuery();

        so, how can i see the statement, that will be sent to the sql-server ? bye jogi

        D Offline
        D Offline
        DoctorMick
        wrote on last edited by
        #3

        Run a trace in SQL Profiler

        J 1 Reply Last reply
        0
        • D DoctorMick

          Run a trace in SQL Profiler

          J Offline
          J Offline
          jogisarge
          wrote on last edited by
          #4

          sorry, i never did hat. can you give a example ?

          M 1 Reply Last reply
          0
          • J jogisarge

            sorry, i never did hat. can you give a example ?

            M Offline
            M Offline
            Mirko1980
            wrote on last edited by
            #5

            SQL Profiler is an application contanined in SQL Server 2005 client tools. You will probably find it installed on your database server, you can also install it on your development machine. With it you can trace queries made on your database. For reference, look here.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups