Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Getting "DB_E_ERRORSINCOMMAND" even when execute is successful

Getting "DB_E_ERRORSINCOMMAND" even when execute is successful

Getting "DB_E_ERRORSINCOMMAND" even when execute is successful

When trying to set the 'max server memory' of a database I use the stored procedure (SP_COFIGURE) as follows:
_bstr_t bstrCommandText = OLESTR("SP_CONFIGURE 'max server memory',");
bstrCommandText = bstrCommandText + bstrServerMemory; // where bstrServerMemory = {"128" (1)}
// looks like = {"SP_CONFIGURE 'max server memory',128" (1)}

iCmd->CommandText = bstrCommandText;
iCmd->Execute(NULL, NULL, adCmdText); // This line generate an error

iCmd->CommandText = L"RECONFIGURE";
iCmd->Execute(NULL, NULL, adCmdText);
However that code generates an except (access violation) on the line that has the comment (above) - not knowing why I changed the code (shown below) to the following so I could "catch" the actual error message and see what was going on...

_bstr_t bstrCommandText = OLESTR("SP_CONFIGURE 'max server memory',");
bstrCommandText = bstrCommandText + bstrServerMemory;

iCmd->CommandText = bstrCommandText;
iCmd->Execute(NULL, NULL, adCmdText);
catch (_com_error cex)
int i; // just to put something

iCmd->CommandText = L"RECONFIGURE";
iCmd->Execute(NULL, NULL, adCmdText);

Now this is much better but has me really confused ..??.. - the error caught (cex) is "DB_E_ERRORSINCOMMAND" - which is odd because it seems to work fine in SQL 2000 itself (Qeury analyzer) just not run via-code as such...
But that isn't the oddest part - if I continue after the exception and then check the server memory settings they have been changed successfully...

So the code WORKS but still throws an error "DB_E_ERRORSINCOMMAND" ... Why? If it works (because I can guarantee that it is correctly changing the max server memory as expected, tested this many times with different values) then why would it send back an error message?
What exactly does it mean? How can I get around this? I don't like my current fix (try/catch that just bypasses the error) - what if there is a REAL error one day? This is really an odd problem and I did some research on the net and couldn't find anything really similar - a few people mention using SET NOCOUNT ON (but I can't edit SP_CONFIGURE)...
Also - this only happens the FIRST TIME it is run, all subsequent times there is NO exception (cex) generated, no "DB_E_ERRORSINCOMMAND" ... this only happens the first time I try to make the changes...

Do I need to Initialize something first? I tried running a "RECONFIGURE" before and after - didn't make a difference...
And I haven't seen a "CONFIGURE" or "INITIALIZE" option - or whatnot like that ... I thought the problem could be that it was returning an empty row/column ... but that is just a theory...

Any help, comments, or hints would be greatly appreciated - I am really at a loss...

RE: Getting "DB_E_ERRORSINCOMMAND" even when execute is successful

Hi and welcome to Eng-Tips.

This set of forums (Eng-Tips) is designed specifically for professional engineers to get help with engineering problems. For straightforward programming questions from computer people that aren't specifically engineering related you will probably do better to join our sister site http://www.tek-tips.com
Tek-Tips is designed for computer professionals rather than engineers so there are specialist forums for all types of computer activity.

When you log on to Tek-Tip use the Find a Forum link to choose the best forum for the language you're using, rather than the SQL forum.

Good Luck
To get the best from these forums read FAQ731-376 before posting

Steam Engine enthusiasts: www.essexsteam.co.uk

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close