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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Which one is the smart coding?

Which one is the smart coding?

Scheduled Pinned Locked Moved ASP.NET
databasequestionsharepointsysadmintutorial
10 Posts 5 Posters 1 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.
  • M Offline
    M Offline
    Mic Mathi
    wrote on last edited by
    #1

    Hi, What is the differents between calling a Stored Procedure like an ordinary sql using 'EXEC' command and by specifying the command type is StoredProcedure? Which one is the faster? //Example of calling stored procedure like an ordinary sql statment Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("EXEC SP_EXAMPLE", Cn) cmd.ExecuteNonQuery() //Example of calling stored procedure with command type is StoredProcedure Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("SP_EXAMPLE", Cn) cmd.CommandType = CommandType.StoredProcedure cmd.ExecuteNonQuery() Thanks and Regards,

    Ken,Mexico(Guanajuato)

    S N V 3 Replies Last reply
    0
    • M Mic Mathi

      Hi, What is the differents between calling a Stored Procedure like an ordinary sql using 'EXEC' command and by specifying the command type is StoredProcedure? Which one is the faster? //Example of calling stored procedure like an ordinary sql statment Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("EXEC SP_EXAMPLE", Cn) cmd.ExecuteNonQuery() //Example of calling stored procedure with command type is StoredProcedure Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("SP_EXAMPLE", Cn) cmd.CommandType = CommandType.StoredProcedure cmd.ExecuteNonQuery() Thanks and Regards,

      Ken,Mexico(Guanajuato)

      S Offline
      S Offline
      Sandeep Kumar
      wrote on last edited by
      #2

      Ken.Hamilton wrote:

      Which one is the faster?

      calling stored procedure like an ordinary sql statement will work faster than the other because in the ordinary method it executes directly the command specified in the sqlCommand() where as in the second case it need to check for the CommandType has it is Stored Procedure so it needs to create a command to execute stored procedure with the specified stored procedure name.

      Regards, Sandeep Kumar.V

      N M 2 Replies Last reply
      0
      • M Mic Mathi

        Hi, What is the differents between calling a Stored Procedure like an ordinary sql using 'EXEC' command and by specifying the command type is StoredProcedure? Which one is the faster? //Example of calling stored procedure like an ordinary sql statment Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("EXEC SP_EXAMPLE", Cn) cmd.ExecuteNonQuery() //Example of calling stored procedure with command type is StoredProcedure Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("SP_EXAMPLE", Cn) cmd.CommandType = CommandType.StoredProcedure cmd.ExecuteNonQuery() Thanks and Regards,

        Ken,Mexico(Guanajuato)

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Ken.Hamilton wrote:

        Which one is the faster?

        There won't be much performance difference. But I think second one is the smarter way.


        My Website | Ask smart questions

        M 1 Reply Last reply
        0
        • S Sandeep Kumar

          Ken.Hamilton wrote:

          Which one is the faster?

          calling stored procedure like an ordinary sql statement will work faster than the other because in the ordinary method it executes directly the command specified in the sqlCommand() where as in the second case it need to check for the CommandType has it is Stored Procedure so it needs to create a command to execute stored procedure with the specified stored procedure name.

          Regards, Sandeep Kumar.V

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Sandeep Kumar Vuppala wrote:

          so it needs to create a command to execute stored procedure with the specified stored procedure name.

          :confused::confused: By specifying new SqlCommand, it already created SQlCommand object. I think there won't be much difference for these two methods. What I feel second method is smarter, because it gives a clear picture to the person who is seeing the code that we are using stored procedures.


          My Website | Ask smart questions

          1 Reply Last reply
          0
          • M Mic Mathi

            Hi, What is the differents between calling a Stored Procedure like an ordinary sql using 'EXEC' command and by specifying the command type is StoredProcedure? Which one is the faster? //Example of calling stored procedure like an ordinary sql statment Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("EXEC SP_EXAMPLE", Cn) cmd.ExecuteNonQuery() //Example of calling stored procedure with command type is StoredProcedure Dim Cn As New SqlConnection("server=.;database=sample;uid=sa;password=;") Dim cmd As New SqlCommand("SP_EXAMPLE", Cn) cmd.CommandType = CommandType.StoredProcedure cmd.ExecuteNonQuery() Thanks and Regards,

            Ken,Mexico(Guanajuato)

            V Offline
            V Offline
            Vasudevan Deepak Kumar
            wrote on last edited by
            #5

            The latter. It is standard, universally adopted practice. There is a proverb "Be Roman while in Rome right?"

            Vasudevan Deepak Kumar Personal Homepage Tech Gossips

            N M S 3 Replies Last reply
            0
            • V Vasudevan Deepak Kumar

              The latter. It is standard, universally adopted practice. There is a proverb "Be Roman while in Rome right?"

              Vasudevan Deepak Kumar Personal Homepage Tech Gossips

              N Offline
              N Offline
              N a v a n e e t h
              wrote on last edited by
              #6

              Vasudevan Deepak Kumar wrote:

              There is a proverb "Be Roman while in Rome right?"

              Great..


              My Website | Ask smart questions

              1 Reply Last reply
              0
              • S Sandeep Kumar

                Ken.Hamilton wrote:

                Which one is the faster?

                calling stored procedure like an ordinary sql statement will work faster than the other because in the ordinary method it executes directly the command specified in the sqlCommand() where as in the second case it need to check for the CommandType has it is Stored Procedure so it needs to create a command to execute stored procedure with the specified stored procedure name.

                Regards, Sandeep Kumar.V

                M Offline
                M Offline
                Mic Mathi
                wrote on last edited by
                #7

                Thank you so much sandeep. I think it is almost same. Isn't it?

                Ken,Mexico(Guanajuato)

                1 Reply Last reply
                0
                • N N a v a n e e t h

                  Ken.Hamilton wrote:

                  Which one is the faster?

                  There won't be much performance difference. But I think second one is the smarter way.


                  My Website | Ask smart questions

                  M Offline
                  M Offline
                  Mic Mathi
                  wrote on last edited by
                  #8

                  Yes you are correct. It is the standard way.

                  Ken,Mexico(Guanajuato)

                  1 Reply Last reply
                  0
                  • V Vasudevan Deepak Kumar

                    The latter. It is standard, universally adopted practice. There is a proverb "Be Roman while in Rome right?"

                    Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                    M Offline
                    M Offline
                    Mic Mathi
                    wrote on last edited by
                    #9

                    You said it. :-D

                    Ken,Mexico(Guanajuato)

                    1 Reply Last reply
                    0
                    • V Vasudevan Deepak Kumar

                      The latter. It is standard, universally adopted practice. There is a proverb "Be Roman while in Rome right?"

                      Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                      S Offline
                      S Offline
                      Sathesh Sakthivel
                      wrote on last edited by
                      #10

                      Vasudevan Deepak Kumar wrote:

                      "Be Roman while in Rome right?"

                      True.

                      SSK.

                      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