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. Using a Stored Procedure in C#

Using a Stored Procedure in C#

Scheduled Pinned Locked Moved C#
csharpdatabasecomquestion
13 Posts 6 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.
  • V Offline
    V Offline
    Vimalsoft Pty Ltd
    wrote on last edited by
    #1

    Good Afternoon All An new in C#, i have been doing Ado.net in vb.net. i want to use a Stored Procedure to do my database work, and i want to tell my command object that we are going to use a StoredProcedure. if i try this cmdselect.CommandType = CommandType = StoredProcedure; I get an Exception that says

    The Name StoredProcedure does not Exists in the current context

    i have googled and my line looked ok, but i dont know what is wrong with this line Thanks

    Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

    O M W B 4 Replies Last reply
    0
    • V Vimalsoft Pty Ltd

      Good Afternoon All An new in C#, i have been doing Ado.net in vb.net. i want to use a Stored Procedure to do my database work, and i want to tell my command object that we are going to use a StoredProcedure. if i try this cmdselect.CommandType = CommandType = StoredProcedure; I get an Exception that says

      The Name StoredProcedure does not Exists in the current context

      i have googled and my line looked ok, but i dont know what is wrong with this line Thanks

      Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

      O Offline
      O Offline
      Obaid ur Rehman
      wrote on last edited by
      #2

      When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. http://msdn2.microsoft.com/en-us/library/x8ybe6s2(VS.80).aspx[^]

      V 2 Replies Last reply
      0
      • V Vimalsoft Pty Ltd

        Good Afternoon All An new in C#, i have been doing Ado.net in vb.net. i want to use a Stored Procedure to do my database work, and i want to tell my command object that we are going to use a StoredProcedure. if i try this cmdselect.CommandType = CommandType = StoredProcedure; I get an Exception that says

        The Name StoredProcedure does not Exists in the current context

        i have googled and my line looked ok, but i dont know what is wrong with this line Thanks

        Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

        M Offline
        M Offline
        mav northwind
        wrote on last edited by
        #3

        Hi! The first place to look for parameters should be the documentation - MSDN still is the authority to ask. Try explaining what your cmdselect.CommandType... line does (not what you want it to do, but what the meaning of the statements you've written is!). You'll see that the two assignments you're performing are nonsense. StoredProcedure is an enum value and you have to tell which enum it's a part of. Btw., you don't get an Exception but a syntax error during compilation - that's a huge difference!

        Regards, mav -- Black holes are the places where God divided by 0...

        V 1 Reply Last reply
        0
        • O Obaid ur Rehman

          When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. http://msdn2.microsoft.com/en-us/library/x8ybe6s2(VS.80).aspx[^]

          V Offline
          V Offline
          Vimalsoft Pty Ltd
          wrote on last edited by
          #4

          hi Thanks for your Reply like this cmdselect.CommandText = "get_me"; cmdselect.CommandType = CommandType = StoredProcedure; "get_me" is the name of the Procedure. and this is how i wrote my code, what is Wrong ? Thanks

          Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

          C 1 Reply Last reply
          0
          • V Vimalsoft Pty Ltd

            Good Afternoon All An new in C#, i have been doing Ado.net in vb.net. i want to use a Stored Procedure to do my database work, and i want to tell my command object that we are going to use a StoredProcedure. if i try this cmdselect.CommandType = CommandType = StoredProcedure; I get an Exception that says

            The Name StoredProcedure does not Exists in the current context

            i have googled and my line looked ok, but i dont know what is wrong with this line Thanks

            Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

            W Offline
            W Offline
            Walaza
            wrote on last edited by
            #5

            //Try the ff: cmdselect.CommandType = System.Data.CommandType.StoredProcedure; cmdselect.CommandText = "Name_Of_StoredProcedure";

            Mvelo Walaza Developer Telkom SA

            V 1 Reply Last reply
            0
            • M mav northwind

              Hi! The first place to look for parameters should be the documentation - MSDN still is the authority to ask. Try explaining what your cmdselect.CommandType... line does (not what you want it to do, but what the meaning of the statements you've written is!). You'll see that the two assignments you're performing are nonsense. StoredProcedure is an enum value and you have to tell which enum it's a part of. Btw., you don't get an Exception but a syntax error during compilation - that's a huge difference!

              Regards, mav -- Black holes are the places where God divided by 0...

              V Offline
              V Offline
              Vimalsoft Pty Ltd
              wrote on last edited by
              #6

              Thanks man i saw the Problem Thanks

              Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

              1 Reply Last reply
              0
              • W Walaza

                //Try the ff: cmdselect.CommandType = System.Data.CommandType.StoredProcedure; cmdselect.CommandText = "Name_Of_StoredProcedure";

                Mvelo Walaza Developer Telkom SA

                V Offline
                V Offline
                Vimalsoft Pty Ltd
                wrote on last edited by
                #7

                Thanks man it Worked Thanks

                Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                W 1 Reply Last reply
                0
                • V Vimalsoft Pty Ltd

                  Thanks man it Worked Thanks

                  Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                  W Offline
                  W Offline
                  Walaza
                  wrote on last edited by
                  #8

                  Glad to know ;)

                  Mvelo Walaza Developer Telkom SA

                  V 1 Reply Last reply
                  0
                  • V Vimalsoft Pty Ltd

                    Good Afternoon All An new in C#, i have been doing Ado.net in vb.net. i want to use a Stored Procedure to do my database work, and i want to tell my command object that we are going to use a StoredProcedure. if i try this cmdselect.CommandType = CommandType = StoredProcedure; I get an Exception that says

                    The Name StoredProcedure does not Exists in the current context

                    i have googled and my line looked ok, but i dont know what is wrong with this line Thanks

                    Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                    B Offline
                    B Offline
                    baala m
                    wrote on last edited by
                    #9

                    :) this is my suggestion check it out. the line should be cmd.CommandType = CommandType.StoredProcedure;

                    V 1 Reply Last reply
                    0
                    • V Vimalsoft Pty Ltd

                      hi Thanks for your Reply like this cmdselect.CommandText = "get_me"; cmdselect.CommandType = CommandType = StoredProcedure; "get_me" is the name of the Procedure. and this is how i wrote my code, what is Wrong ? Thanks

                      Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                      C Offline
                      C Offline
                      Colin Angus Mackay
                      wrote on last edited by
                      #10

                      Vuyiswa wrote:

                      and this is how i wrote my code, what is Wrong ?

                      Since this code would generate a compiler error, surely the error message would be able to pinpoint where the error is. Try: cmdselect.CommandType = CommandType.StoredProcedure; Note the dot instead of the second equals sign.

                      Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Mixins in C#3.0 My website | Blog

                      1 Reply Last reply
                      0
                      • O Obaid ur Rehman

                        When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. http://msdn2.microsoft.com/en-us/library/x8ybe6s2(VS.80).aspx[^]

                        V Offline
                        V Offline
                        Vimalsoft Pty Ltd
                        wrote on last edited by
                        #11

                        Thanks it worked

                        Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                        1 Reply Last reply
                        0
                        • W Walaza

                          Glad to know ;)

                          Mvelo Walaza Developer Telkom SA

                          V Offline
                          V Offline
                          Vimalsoft Pty Ltd
                          wrote on last edited by
                          #12

                          Thanks Bro

                          Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                          1 Reply Last reply
                          0
                          • B baala m

                            :) this is my suggestion check it out. the line should be cmd.CommandType = CommandType.StoredProcedure;

                            V Offline
                            V Offline
                            Vimalsoft Pty Ltd
                            wrote on last edited by
                            #13

                            Thanks i get your point

                            Vuyiswa Maseko, Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding VB.NET/SQL7/2000/2005 http://vuyiswamb.007ihost.com http://Ecadre.007ihost.com vuyiswam@tshwane.gov.za

                            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