Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MFC, Exec Stored Procedure - SQL DB

Posted on 1998-11-30
5
Medium Priority
?
973 Views
Last Modified: 2013-11-20
Hi All,
I am trying to read info from SQL server DB using the stored procedures. I have created a class derived from CRecordset using MFC, opened it using Open fn. Here is the code,

CString csSql = "exec StoredProcedureName" ;

CDatabase dbMyDB ;

dbMyDB.OpenEx("DSN=DSNName;UID=UserId;PWD=Password") ;

CMyRecordSet cMyRSet(&dbMyDB) ;

cMyRSet.open(CRecordset::snapshot, csSql) ;

Navigate the result set....

I am getting the RunTime error(not the compile time error).
"Incorrect Syntax near the keyword exec"
Do you have any idea? Whats wrong?


0
Comment
Question by:svdam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 1

Accepted Solution

by:
Bridge earned 40 total points
ID: 1325546
use CALL instead of EXEC
0
 

Author Comment

by:svdam
ID: 1325547
I tried with CALL but I got the error "Invalid object Name CALL"
I would appreciate if you can suggest me some more solutions/methods.


Thanks with regards
dam
0
 
LVL 1

Expert Comment

by:guruprasad031298
ID: 1325548
Try this

CString csSql = "{CALL StoredProcedureName}" ;

Should work fine
0
 

Author Comment

by:svdam
ID: 1325549
Thanks Bridge's and GuruPrasad.  I solved the problem before I see the answer(guruprasad). Anyway Thanks a lot.
csSQL = "{ call SPName } ;
worked fine.

Thank you
Dam



0
 

Author Comment

by:svdam
ID: 1325550
Thanks Bridge's and GuruPrasad.  I solved the problem before I see the answer(guruprasad). Anyway Thanks a lot.
csSQL = "{ call SPName } ;
worked fine.

Thank you
Dam



0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question