Solved

MFC, Exec Stored Procedure - SQL DB

Posted on 1998-11-30
5
940 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
  • 3
5 Comments
 
LVL 1

Accepted Solution

by:
Bridge earned 20 total points
Comment Utility
use CALL instead of EXEC
0
 

Author Comment

by:svdam
Comment Utility
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
Comment Utility
Try this

CString csSql = "{CALL StoredProcedureName}" ;

Should work fine
0
 

Author Comment

by:svdam
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how do i create updater to My Activex application? 3 74
Generic progress indicator 6 109
modThree challenge 4 64
MaxSpan challenge 9 65
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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now