|
Hi All,
Thanks in advance.
I am not able retrieve the out parameter values from an SQL Server stored procedure using ADODB::_CommandPtr. It is working fine with Oracle stored procedure.
The code..
ADODB::_ConnectionPtr m_objConn;
ADODB::_CommandPtr m_objCmd;
_variant_t vtEmpty1(DISP_E_PARAMNOTFOUND, VT_ERROR);
_variant_t vtEmpty2(DISP_E_PARAMNOTFOUND, VT_ERROR);
_bstr_t bstrSP("sp_MyTestSP");
_variant_t vtValue;
_variant_t vtName;
m_objConn.CreateInstance( __uuidof( ADODB::Connection ) );
m_objCmd.CreateInstance( __uuidof( ADODB::Command ) );
m_objConn->Open(lpszCnnStr, lpszUserName, lpszPwd, NULL);
m_objCmd->ActiveConnection = m_objConn;
m_objCmd->CommandText = bstrSP;
m_objCmd->CommandType = ADODB::adCmdStoredProc;
m_objCmd->Parameters->Refresh();
m_objCmd->Parameters->Item[_variant_t("@EmpId")]->Value =_variant_t((long)10);
objTable.m_pstRecSet = m_objCmd->Execute(&vtEmpty1, &vtEmpty2, ADODB::adCmdStoredProc);
/*check for the output paramaters*/
for(pp =1; pp < m_objCmd->Parameters->Count; pp++)
{
switch(m_objCmd->Parameters->Item[_variant_t((long)pp)]->GetDirection())
{
case 2:
case 3:
vtName = m_objCmd->Parameters->Item[_variant_t((long)pp)]->GetName();
sprintf(pszDest, "%s=", (LPCSTR)((_bstr_t)vtName));
vtValue = m_objCmd->Parameters->Item[_variant_t((long)pp)]->Value;
if(VT_NULL != vtValue.vt)
sprintf(pszDest, "%s%s", pszDest, (LPCSTR)((_bstr_t)vtValue));
break;
default:
break;
}
}
This code works fine with oracle stored procedures. But i am getting NULL when i use it with SQL Server stored procedures.
What could be the problem? Please help me.
Shyju.
|
|
|
|
|
Hello I am trying to draw a box and a message in a console window like so:
**************
* *
* Hello name *
* *
**************
Instead it looks like this:
**************
* *
* Hello name
* *
**************
This is my code that I am trying to get work:
<br />
int main(int argc, char *argv[])<br />
{int r=1,row=0,col=0,c=1;<br />
string name,greet;<br />
<br />
cout << "Please enter your name";<br />
cin >> name;<br />
greet = " Hello " + name +" ";<br />
<br />
row = 5;<br />
col = greet.size()+2;<br />
<br />
for(r=1;r<6;r++){<br />
for(c=1;c<=col;c++){ <br />
if(c==1 || r==1 || r == 5 || c==col)<br />
cout<< "*";<br />
else if(r==3 && c>1 && c<col-1) {<br />
cout<<greet;c+= greet.size();}<br />
else<br />
cout<<" ";<br />
}<br />
<br />
cout<<endl; }<br />
<br />
system("PAUSE");<br />
return EXIT_SUCCESS;<br />
}<br />
The top one should be a box and the second one should be a box but missing an asterisk right after name.
|
|
|
|
|
You need to change your line
c += greet.size();
to
c += greet.size() - 1;
since you've already advanced to position 1 and you want to only add the size of greet , you must subtract one from greet 's size.
"we must lose precision to make significant
statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Thanks, the program is working perfectly now.
|
|
|
|
|
Glad to hear it. Have fun programming!
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi all. Thanks for listening...Well, reading i mean.
Anyway, I want to develop a console application in vs 2003 that has the looks and visual functions of the turbo c compiler.
What i mean is that i want an application in the console that has a main menu, scroll bars etc...(I dont want to develop a compiler(for god's sake))
But i have a series of critical problems:
- I cant "tell" my program whether i want it to be text screen mode 25x80 or 40x80 (is there any command or function for that?)(Personally i prefer it 25x80)
- I want it to run by default as a full screen ms dos and not as a window
- I try to draw a "window" that takes the whole screen like this one:
╔═════════╗
╚═════════╝
with characters
but printing and printing, i finally get to the last place of the last line of the last column.Printing the last character the typical commands like cout produce an end line and i lose the first line.
I want some advice on how to do such a thing as a console window.
- I want to add mouse support
- I want to add multilanguage support
Anyone who thinks he knows something or is thinking of something about it please share it.
Remember i am using VS 2003 .net
Also i dont know if programming in win32 console or .net console has many functional differences
Thank you
|
|
|
|
|
Hi, I have the following lines of code that fail once the function GetNodeContent returns "0", how can I differentiate the S"0" and the null value 0??? since a S"0" for me would mean that the status node has a S"0" value, and 0 would mean that the node wasnt found, however if the attribute is found with a "0" value the code breaks
if ((temp = GetNodeContent(nav, "/Comprobante/@status")) != 0)
this->Status = temp;
else
throw new Exception("Field required");
//*************
String* CFD::GetNodeContent(XPathNavigator *nav, String *expression)
{
XPathExpression *expr = nav->Compile(expression);
XPathNodeIterator *iterator = nav->Select(expr);
String *s;
while (iterator->MoveNext())
{
s = iterator->Current->Value;
}
return s;
}
Thanks in advance
Isaac B
|
|
|
|
|
Use NULL if you use managed C++ extension, and nullptr if you use C++/CLI.
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
You should set s to 0 to begin with: String *s = (String*)0; Or String *s = NULL;
The string "0" and the value 0 are two totaly different things. If a pointer to the string "0" is returned, you have a pointer to a valid address (which is not 0). If value returned is 0 then you have a pointer to address 0x00000000, which is an invalid address.
String *s = GetNodeContent(...);
if( !s ) {
}
INTP
Every thing is relative...
|
|
|
|
|
Having got used to typing public static in C#, I tried writing the same in C++/CLI and sure enough, the compiler gave an error. Instead of changing it to
public:
static ...
I mistakenly modified it to static public instead. Surprisingly, it compiled fine. Examining the IL using Reflector showed that it had no effect, the method was private.
Is this a compiler bug or am I missing something?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i would go to the bug direction... what compiler did you use to try this ??
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
This was written in VC++ 2005 Express Edition, so it must be using the VC++ 8.0 compiler.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I know how to use winAPI to get the current drive contents with no problem but I am trying to write a shell program that will work on all operating systems.
Does anyone know how i can gather the drive contents of the current drive using just the standard C functions? No API and no MFC.
This is my first dos/shell command prompt program, please excuse my dumbness I am used to using API functions for everything.
Thanks for any suggestions or pointing me in the right direction.
|
|
|
|
|
You could use the CRT functions _findfirst and _findnext .
Regards,
Nish
|
|
|
|
|
Hmm.. I find your question interesting! I think you don't understand the meaning of API and/or the nature of C/C++. C/C++ is just a language. It is just a means of "using" an API. So to answer your question, there is no actual function that you could be sure would be supporting by any operating system in order to get the file structure. This is why for your case to be realistic you should start by making a list of the operating systems you would like your application to support. Only after that you can try to find a function that is supported on all of those systems (such as the _findfirst, _findnext functions the Nishant suggested). And for the operating systems that don't support those functions (in case ther will be any) you will have to provide the functions yourself.
|
|
|
|
|
I am very new to C++ and was just wondering how to create and write a csv file.
I am creating a simulation model for TB transmission and I have a list of people objects each with various attributes (age, gender, ID number, TBStatus etc) and i need to write the details of each person to file after each year of the simulation. The file would look like this:
ID#, age, sex, TBStatus etc...
1,52,0,0
2,3,0,1
3,21,1,2
Is this something to do with StreamWriter?
I would really appreciate some help with this.
Thanks
Georgie
|
|
|
|
|
If you're using managed C++, then yes, the StreamWriter is what you want. However, I'd recommend using ofstream instead/.
#include <fstream>
using std::ofstream;
ofstream str(filePath);
str << ID << ", " << age << ", "
etc.
Now, if these things are stored in a struct, you could look at my <a href="http://www.codeproject.com/vcpp/stl/iostreaminserters.asp" rel="nofollow">article</a>[<a href="http://www.codeproject.com/vcpp/stl/iostreaminserters.asp" target="_blank" rel="nofollow" title="New Window">^</a>] on how to stream custom types, then you could do it all in one line and code the commans into the inserter.
Christian Graus - Microsoft MVP - C++
-- modified at 17:00 Tuesday 15th November, 2005
|
|
|
|
|
Thanks so much for this.
I've got that all working so its very much appreciated.
Thanks
Georgie
|
|
|
|
|
There is a thread in windows form application.
I start several instances of this thread, and within its code it opens and closes from time to time a file on disk.
How to organize exclusive access to this file from several instances of a thread.
Thread:
...
...
open the same file //need to wait while this file is opened in
read data from it //another instance of this thread
write data to it
close file
...
...
...
..etc.. for file operation
...
...
9ine
|
|
|
|
|
Hello all,
I have a fully functional Visual C++ .NET console application that draws an ASCII character map at run-time in a DOS window. How can I start a window and draw the map real-time to that window as opposed to the DOS window? I have very little experience with Windows graphics so any advice would be greatly appreciated on how to start the window, draw to it, etc ...
By the way, the map I need to draw is simply a grid with different squares in the grid having different colors.
Thanks guys and girls.
|
|
|
|
|
As Windows is an event based system, all drawing happens in an event called OnPaint. If you're using C++/CLI ( managed C++ ), you can use the FillRectangle method of the graphics object to draw rectangles of different colors to the screen. If this is an MFC app, then the CDC class has similar methods, but there's more work involved, and more margin for error, in terms of resource leaks, etc.
If you clarify which one it is, I'd be glad to offer more advice if needed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hello Christian,
Thanks for the quick reply. If you bare with me a little longer, we'd be able to figure this out. Much appreciated.
I have Visual Studio .NET and the program I wrote is simply an MS-DOS console project that I started as an "empty project" in VS.NET (C++ Projects). This is my second time using VS, I have been programming in VC6 until recently. The program runs fine as an .EXE under DOS. It draws a grid map that is updated in a seperate thread from a class that the main thread updates, in other words, the main thread creates the map class, updates its members, and a drawing thread automatically and simultaneously reads from the map class object and updates the graphic grid.
Now, I would like to move the graphics to a window as opposed to the DOS console. It seems from your reply that managed C++ is a better way to do that, and given that I know neither managed C++ graphics nor C++/MFC, might as well learn C++/CLI and use that.
This is what I'm trying to do. Any further reply is much much appreciated.
Thanks.
|
|
|
|
|
One more thing. My impression is that VS.NET allows you to program parts of an application in C++, part in VB, and so on. Would having VB do the drawing be easier than drawing with Managed C++? And if so, how can VB see the map's class and draw from it?
Thanks Christian (and all).
|
|
|
|
|
Big_Goose wrote: My impression is that VS.NET allows you to program parts of an application in C++, part in VB, and so on.
Yes, if you write part of it in dlls. There's rarely a good reason to do this, I've only just done it for the first time ever ( I wrote some really complex image processing code in C++, and now I have a C# app that wants to call it ).
Big_Goose wrote: Would having VB do the drawing be easier than drawing with Managed C++?
Yes.
Big_Goose wrote: And if so, how can VB see the map's class and draw from it?
You'd have to write a MC++ dll that exposes methods to return the data. I'd be surprised if it wouldn't be easier to rewrite it in VB or C#.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Big_Goose wrote: Now, I would like to move the graphics to a window as opposed to the DOS console.
OK - if you've used standard C++ so far, I'd be inclined to use MFC. An MFC app should be able to run the code you've already written, and then you can use the OnPaint method of the View class to draw your grid.
managed C++ is what I still call what is now C++/CLI, because I've never used either
If you already know C++, then MFC is probably the way to go. If you want to learn VB.NET or C#, then you need to turn your C++ code into a DLL which returns the data that needs to be rendered, or convert it to one of those languages.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|