Re: Quick code to execute an SQL stored procedure.



First let me state that I appreciate the help that all people give in the news groups. Especially the MVPs. It is huge job that is done well.


Your answer is worthless to me. And here is why. I know nothing about these databases and everything you Googled for me is so complicated. I had already Googled similarly and I have already gotten so confused. I was hoping there would be a simple answer.

I seriously though that what I needed to do was so simple. I was hoping that I could learn everything I needed to know in an afternoon, maybe less. (Remember I know ZERO about databases.)

I figured that a stored procedure is like a function call to a database. You provide some data as parameters and the procedure does its stuff and then returns a code to you. I thought this would be just like a function call.

So... Dummy me... Thinks that maybe this could be done in maybe... Only 3 lines of code. Silly me to think this was possible. I thought maybe the three lines would be.

1) Code line #1. Some kind of open statement where I specify the server, database name, login and password. I figured I'd get some kinda handle or something.

2) Code line #2. I'd use the handle and then call some kind of execute command or something where I specify the name of the stored procedure and the parameters. I figured I'd get a return code.

3) Code line #3. Some kind of close statement to close the database access.


I was hoping to get an answer with those types of details. I guess I was wrong.



So you say why would I think this??? What I remember about databases from the past was some work I did with MySQL. I'd open a command window. I'd execute a MySQL command giving the database name, password and stuff and then BOOM I'm in the database. Super simple. Then I can do a SELECT statement and BOOM I get all this data. Thats great.

I just figured how hard could it be to execute a stored procedure!



AliR (VC++ MVP) wrote:
http://support.microsoft.com/kb/183001

Let me google that for you:
http://letmegooglethatforyou.com/?q=MFC+stored+procedure

AliR.

"Beamer" <BeamerS@xxxxxxxxx> wrote in message news:Cy%kl.10396$hc1.2087@xxxxxxxxxxxxxxxxxxxxxxx
I haven't written code to access a database in many years. I now have a requirement in my MFC version 6 program to execute a stored procedure. The database is Microsoft SQL Server 2005. I know the server name, database name, login and password. I also know the sored procedure name and the parameters.

How exactly do I execute the stored procedure? I assume I need to open the database and then do something to execute the stored procedure.


.



Relevant Pages

  • Re: Quick code to execute an SQL stored procedure.
    ... There are alot of post where people don't google for an answer, ... But you are right I googled for "MFC Stored Procedure In 3 Lines of Code" ... I figured that a stored procedure is like a function call to a database. ... I'd use the handle and then call some kind of execute ...
    (microsoft.public.vc.mfc)
  • Re: Execute stored procedure only
    ... You need CONNECT capability to be able to get into the database and execute ... You can compare this to having permission to eat a piece of pie, ... Should I not be able to just execute SP through QA? ... right to execute stored procedure in database called "mydatabase". ...
    (microsoft.public.sqlserver.security)
  • Re: Extended Stored Procedure: Get the current db of the client
    ... with the caveat that you don't recommend it because Microsoft ... of a stored procedure versus umpteen of the same stored procedure spread ... I am not going after Gert Sue. ... the database context as a parameter if you need it, ...
    (microsoft.public.sqlserver.odbc)
  • Trying to set up a SQL Server Agent Account and I hit a wall....
    ... Our database is on SQL Server 2005, however it is set to compatibility mode ... You may need to set the compatibility level ... of the current database to a higher value to enable this feature. ... for the stored procedure sp_dbcmptlevel. ...
    (microsoft.public.sqlserver.security)
  • Re: Extended Stored Procedure: Get the current db of the client
    ... I am not going after Gert Sue. ... the database context as a parameter if you need it, ... Did you ever write an extended stored procedure? ... different than an extended stored procedure, so that is not giving you want ...
    (microsoft.public.sqlserver.odbc)

Loading