Using a Stored Procedure in C#
-
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 saysThe 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
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...
-
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[^]
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 ? ThanksVuyiswa 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
-
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 saysThe 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
-
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...
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
-
//Try the ff: cmdselect.CommandType = System.Data.CommandType.StoredProcedure; cmdselect.CommandText = "Name_Of_StoredProcedure";
Mvelo Walaza Developer Telkom SA
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
-
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
-
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 saysThe 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
-
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 ? ThanksVuyiswa 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
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
-
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[^]
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
-
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
-
:) this is my suggestion check it out. the line should be cmd.CommandType = CommandType.StoredProcedure;
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