Problems implementing SQLCommand

  • Thread starter Thread starter Phenom
  • Start date Start date
P

Phenom

I am attempting, for the first time, to use SQLCommand in asp.net . My
ultimate goal is to utilize a stored proc. When I use the following
code to begin, I get several error messages. I hope someone can explain
these to me and let me know what I need to do to correctly implement
the SQLCommand in my code.

Public NotInheritable Class SqlCommand
Inherits System.ComponentModel.Component
Implements IDbCommand, ICloneable

End Class

The messages I get are :
1)'Approved.SQLCommand' must implement Overrideable Sub Prepare() for
interface 'System.Data.IDbCommand'
2)'Approved.SQLCommand' must implement Overrideable Function Clone() as
object for interface 'System.ICloneable'

I did attempt to add Function Clone() as object and seemed to open up
another can of worms. I have spent many hours on the internet and
looking through MSDN material but am either not understanding or not
finding exactly what I need.
Thank you in advance for your help.
 
Is this your own class definition? If so, do you have the methods as
specified by the interfaces? That looks to be the culprit here. You don't
need to create your own SqlCommand class, the standard SqlCommand already
can handle stored procedures so if the code you specified is what you are
actually using, you are probably headed in the wrong direction.

You can just use SqlCommand like this:

SqlConnection cn = new SqlConnection("CONNECTIONSTRING");
SqlCommand cmd = new SqlCommand("StoredProcedureName", cn);
cmd.CommandType = CommandType.StoredProcedure;
cn.Open();
cmd.ExecuteNonQuery();
cn.Close();
//Obviously I'm leaving out all the exception handling

If however I misunderstood your question, can you please tell me a little
more abou thte scenario and I'll see what I can do.

Cheers,

Bill
 
Thanks. You're right. I think I'm making it too hard on myself. I
appreciate it. I'll post back if I have more trouble.
Tawnya
 
So I'm not the only one that tried to hard when I was learning ;-) It can
be a little frustrating at first but fortunately, it gets easier pretty
quickly.

If you run into any problems, let me know and I'll do what I can.
 
Actually, I'm trying to read whatever I can get my hands on. This is my
first attempt at .NET. I'm so used to the procedural approach of ASP,
this is taking a little bit of a mindset change to switch back to the
old days when I did VB stuff. (We're talking almost a decade ago).
What's the title of your book? When will it be in print? I haven't
followed your link yet to see if your info is there....
 
Mine is on the shelves now: See www.betav.com.


--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________
 
Back
Top