|
_bstr_t str;
str= "SELECT * FROM Tennis ORDER BY Name";
if( pDoc->m_pConnection==NULL )
return ;
_variant_t vRecsAffected(0L);
try
{
pRecordSet = pDoc->m_pConnection->Execute( str, &vRecsAffected, adOptionUnspecified);
.
.
.
I recevie run time error for Execute() line,in output window:
Exception thrown for classes generated by #import
Code meaning = Unknown error 0x800A0BB9
Source = ADODB.Connection
Description = Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
you initialize str - that's ok
but what is "sqlstring"?
regards, b.
|
|
|
|
|
sqlstring is sql;) Thats something I missed when I copy/paste my codes here.Now I have to correct it.So my Problem is not solve.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
Also:
When I debug that line for str I see that it is "Bad Ptr" and "CXX0030: Error: expression cannot be evaluated".
So there is a problem with that?Does anybody know whats that?
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
try _bstr_t str = L"sfjdsfhsdfh";
|
|
|
|
|
no,that does not help
Thanks for reply
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
In my experience, when you get a bad args error, it's more than likely that it's your SQL that's at fault. How about:
SELECT * FROM [Tennis] ORDER BY [Tennis.Name]
Just a guess...
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Thank you Derek,I found the problem before,It was because of openning my database,my database was openned so it caused runtime error.
Thank you again.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
i declare a function pointer like this:
void (*PTestFunc)(CString& str);
and two classes:
class CTest
{
...
void Test()
{
m_pTestFunc(CString("fdsaf"));
}
void SetFuncPointer(void* pointer)
{
m_pTestFunc = pointer;
}
PTestFunc m_pTestFunc;
...
}
class CMyClass
{
...
CString m_strCaption;
void MyTest(CString& str);
void Init(CTest& test);
...
}
CMyClass::MyTest(CString& str)
{
m_strCaption = str;
}
void CMyClass::Init(CTest& test)
{
test.SetFuncPointer((void*)MyTest); //error c2440
}
//////////////////////////////
if i add "static" before MyTest, it is right;
but u see i need this pointer in my class, i can't set MyTest static. so how to solve this problem? does c++ define the class member function pointer?
c++ : my dream
|
|
|
|
|
|
Not sure if this will solve your problem
http://www.codetools.com/script/comments/forums.asp?forumid=1647&app=50&fr=251#xx142181xx
Todd Smith
CPUA 0x007 ... shaken not stirred
|
|
|
|
|
"Browse for Folders from the Current Directory" topic ( http://support.microsoft.com/default.aspx?scid=kb;EN-US;q179378 ) describes how to Browse for Folders from the Current Directory using SHBrowseForFolder function. But it was not works correctly when using "network path" like "\\SomeComputer\SomeFolder\Folder".
gCan you help me?
|
|
|
|
|
I've not used it for network browsing, but I know it has a flag for browsing networks ? Have you tried that ? What is going wrong ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Check this code: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q179378
.
.
.
INT CALLBACK BrowseCallbackProc(...)
{
.
.
.
case BFFM_INITIALIZED:
// !!!
if (GetCurrentDirectory(sizeof(szDir)/sizeof(TCHAR), szDir)) {
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)szDir);
.
.
.
If GetCurrentDirectory(...) is a directory with a simple path (e.g. D:\WinNT\System32) SHBrowseForFolder work correctly - select folder D:\WinNT\System32 in tree,
but if GetCurrentDirectory(...) is a directory with "network path" (e.g. \\SomePC\SomeFolder) SHBrowseForFolder does not selects this path.
You can check it: just run this sample from net directory.
|
|
|
|
|
Ok,... I finished a bunch of more reserch and these are the things in which i either didnt exactly understand or just questions at random about certain things that i would like to know...
To organize this, if you want to: write the thing that you are weilling to help with in the subject for the reply. "This will make it easier to reply to your answers " And for any other newbie around may find help in this thread.
~Hex Dec Oct: What is the differance and why use them seperat from each other.
~Globals: How do you decalare a global inside of a little program? or change them around? I had my main program read through somthing that looked like this...
int main()
if(boolone = true);first();
if(booltwo = true);second();
and so on...
then i wanted it so that when your inside of the program first, there would be a gets or cin and if you typed in one off, the program would set the boolone to false and the program wouldnt read anything in there. I could have done somthing extreamly wrong and stupid in the program, but everything checked out and it still didnt work...
~MFC - C++: Ive asked this question before... im going to build a game engine that would allow me to build 2D games that i would like to host over the internet... The engine i would like it to be all in windows, but what language or toolkit should i use? MFC or C++, what one would give me more flexibility and make the job allot less work than it already seems to be?
~Null: Ive seen the 'null' statement used all the time, but i dont know what it is used for. "i think this is a vary newbie question but you know "
~Clear Screan: When ive bean building line based games in DOS ive always wanted to clear the screan for that the game would look slightly better... How do i do this? "Ive asked this one before also sodo be annoyed "
~Switch (break and continue): I understand the switch "I think" but im not to sure on break and continue commands... How do i use them?
~Delete: how do i use this? and what is the syntax?
~Public: I looked this one up, but didnt understand. Public: its not a goto statment is it? (dont think so) why use this? also, there is a private: one, how do you use these and why?
~return: Return like in the int main() and return 0; i understand, but... there is other things that you can do with the return statment that i dont quit get... can any one help?
~Get line: What does a get line do? and what is the syntax for doing so?
~#if and #define and #endif #else... : why is there a # sign on these? and the define, what does it do, or what is its purpose?
~std::stream: What does this do?
~std::fstream: what does this one do, and what is its differance to the other one?
~if stream and stream: what do these do? "these last ones are just a (curiosity) and could probably help allot in the future.
~Class: what is a class used for?
~Sound: I really desire to make a sound engine for my game, "and if not in my game" just somthing that would be fun to program and mess around with. But i dont know exactly where to start with the sound and how to send sound to the speakers. Can anyone help in this?
Well, thats all, "allot of questions like i said" but this is like a week of reading and toiling with out asking any at all " Some of the questions may be stupid and some maybe so lame or easy that maybe a quick syntax would help Sorry for the annoyance "to those who this annoys..."
Thanks all for hum responds... and for viewing this thread.
~SilverShalkin
I did have a cool poem that i made up, but
i left it in my graphics class, and the last
time that i posted, i reposted it on a poetry forum
and they said it sucks "that was them being
nice... So next one, after posting it onto the
poetry forum, ill post it here
|
|
|
|
|
~ Hex, Dec, Oct... First, you have to remember that everything to a computer is just a binary number. Hex, Dec, oct are just different ways we use to make those binary numbers readable to humans. Decimal is what we are use to from our youth. Hex is very handy with 8bit systems where 2 hex digits represent the byte of data. Octal is really an outdated system.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Tim Smith wrote:
Hex is very handy with 8bit systems
Ill keep that in mind so.. i shouldnt really bother with octals?
Thanks for your time
~SilverShalkin
Srcatch another
|
|
|
|
|
SilverShalkin wrote:
i shouldnt really bother with octals?
The key thing is that unless you're displaying the values, the computer doesn't actually care, it's just going to turn it into binary anyhow.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
globals are variables or objects that are available to a whole program rather than to just a function or a class., You declare them outside any function or class. Now the whole application can use it. If you have multiple source files you'd have to redeclare them in each of thise files using extern.
Nish
I am the Keyboard Smasher
|
|
|
|
|
you redefine the globals with extern? could you use that in an example? or does it look something like...
int first();
bool one = false;
int main()
{
first()
}
first()
{
extern one "Im just guessing "
}
Thanks...
~SilverShalkin
Scratch one
|
|
|
|
|
Let's say you have two files
a.cpp and b.cpp
Now if you have an int y in a.cpp and an int y in b.cpp, they'd be two separate ints. The idea of a global is to make it application global.
This instead of int y you should declare them as extern int y which tells the compiler than this variable has external linkage. Thus in the final executable this will be a single global variable
Nish
I am the Keyboard Smasher
|
|
|
|
|
SilverShalkin wrote:
~Hex Dec Oct: What is the differance and why use them seperat from each other.
Hex: base-16 number system. Valid "digits" are 0-9 and A-F (A=10, B=11, .., F=15). More convenient to use and easier to read than binary.
Dec: The number system you've used since you started learning.
Oct: base-8 number system. Valid "digits" are 0-7. Alternative format for binary number. Used with the Unix command chmod, for example.
SilverShalkin wrote:
~Switch (break and continue): I understand the switch "I think" but im not to sure on break and continue commands... How do i use them?
Compares discrete values. For example, if you have a set of integers, you can handle each case separately:
switch(someValue)
{
case 0:
break;
case 1:
case 2:
break;
default:
break;
}
break in this case breaks you out of the switch statement so that, if someValue == 0, you don't keep executing the handlers for 1/2 and the default. break will also break you out of a loop.
continue will take you back to the top of a loop without having to execute it all the way to the end. Useful if you know that you don't want to finish processing an iteration, and you just want to move on to the next one.
SilverShalkin wrote:
~Delete: how do i use this? and what is the syntax?
Use this to free memory you created dynamically on the heap.
char *pChr = new char;
delete pChr;
char *pStr = new char[256];
delete [] pStr;
You could also use NULL here. Since you can't reference the memory that both pChr and pStr used to point to, you should set the to NULL (i.e., nothing).
pChr = NULL;
pStr = NULL;
Jon Sagara
There is no spoon.
Best Miniputt score: 21
|
|
|
|
|
SilverShalkin wrote:
~Public: I looked this one up, but didnt understand. Public: its not a goto statment is it? (dont think so) why use this? also, there is a private: one, how do you use these and why?
By default, methods and members of classes are private. In order to make them accessible outside of the class, you need to declare them as public.
class CMyClass
{
public:
protected:
private:
public:
};
I'm tired. I'm going home. Maybe someone else can pick up where I left off.
Jon Sagara
There is no spoon.
Best Miniputt score: 21
|
|
|
|
|
SilverShalkin wrote:
Hex Dec Oct: What is the differance and why use them seperat from each other.
The difference is what base they use. We use decimal because we have 10 fingers, so it was natural in the evolution of math that we consider 10 to be the number that requires one more significant figure. Computers think in binary, which meshes nicely with base 8 (octal ) and base 16 (hex). I've never seen oct used for anything in particular.
The Windows calculator program can show you how the same number is displayed in the different bases, or look at my ostringstream article for a way to stream a number out as different bases. It works the same way if you're just streaming to cout.
SilverShalkin wrote:
Globals: How do you decalare a global inside of a little program?
Just by declaring it. Any variable declared outside of a class or function is global. When you're doing it in C++, the best way is to use extern, which tells the compiler a variable exists, but does not declare it. use extern int i in stdafx.h, and int i in stdafx.cpp to make a variable visible everywhere.
You would be foolish not to wrap such variables in a namespace, so that they have some protection from corruption. Even then, avoid globals if you can.
SilverShalkin wrote:
MFC - C++: Ive asked this question before... im going to build a game engine that would allow me to build 2D games that i would like to host over the internet... The engine i would like it to be all in windows, but what language or toolkit should i use? MFC or C++, what one would give me more flexibility and make the job allot less work than it already seems to be?
MFC is a library that you use in C++, you probably mean MFC or Win32. MFC will take a lot of work away because of the stuff it gives you for networking and so on, but I'd suggest Win32 with DirectX, because you'll need DX anyhow for DirectDraw, and it gives you the networking stuff as well, in DirectPlay.
SilverShalkin wrote:
Null: Ive seen the 'null' statement used all the time, but i dont know what it is used for. "i think this is a vary newbie question but you know
A pointer that does not point to a valid address should point ot 0. Calling delete on such a pointer will not do anything. NULL is a #define, it equates to (void*) 0.
SilverShalkin wrote:
Switch (break and continue): I understand the switch "I think" but im not to sure on break and continue commands... How do i use them?
You don't use continue in break statements. If you don't use a break in a switch, it falls through, like this:
int i = 0;
switch (x)
case 0:
i = 7;
default:
i = 10;
In this case i will always equal 10, because even the case 0 will fall through and the defaul will also execute.
contine and break are used in loops, break stops the loop and continue jumps to the next iteration, so the loop continues but any other code is not executed for this iteration only.
SilverShalkin wrote:
Delete: how do i use this? and what is the syntax?
If a variable is a pointer, then it vecomes an object when it is created with new, and the memory is deallocated and the destructor called when delete is called. You should also set this pointer to NULL.
int * p = new int;
*p = 7; // NOT p = 7, that sets the memory address, not the value )
// use p
delete p;
*p = 5; // ERROR - memory is deallocated
p = NULL;
SilverShalkin wrote:
Public: I looked this one up, but didnt understand. Public: its not a goto statment is it? (dont think so) why use this? also, there is a private: one, how do you use these and why?
In a class, you have functions and members. Anything that is public is visible by anyone who has an instance of a class. private is visible only to the class itself. Often variables are made private and exposed through methods that can validate the data being put into a variable. For exmaple if 0-100 is a valid range for a variable, the closest I can get is a char or unsigned char, but I need to validate the values coming in, or I could get values between -127 and 127, or 0 and 255.
SilverShalkin wrote:
return: Return like in the int main() and return 0; i understand, but... there is other things that you can do with the return statment that i dont quit get... can any one help?
All you can do is return a value. What don't you get ?
SilverShalkin wrote:
~#if and #define and #endif #else... : why is there a # sign on these? and the define, what does it do, or what is its purpose?
Because they are processed by the preprocessor. They can be used to create different versions ( such as debug and release ) or to create macros. The preprocessor uses them to decide what code is passed to the compiler.
SilverShalkin wrote:
~std::stream: What does this do?
~std::fstream: what does this one do, and what is its differance to the other one?
~if stream and stream: what do these do? "these last ones are just a (curiosity) and could probably help allot in the future.
Is there a std::stream ? Surely it's a base class. IOStreams are part of the standard library. A fstream is a bidirectional file stream, ofstreams and ifstreams also exist. Read my article on ostringstream - ofstream works the same way, and both work the same way as cin/cout.
SilverShalkin wrote:
Class: what is a class used for?
To encapsulate a block of logic. For exmaple, MFC has a CPoint class, it encapsulates the data and operations one might do on a point. I can create an instance of a CPoint and I can add them together, compare them, etc. It's a powerful tool to hide implimentation details from users of an object, and also simple to organise code.
SilverShalkin wrote:
Sound: I really desire to make a sound engine for my game, "and if not in my game" just somthing that would be fun to program and mess around with. But i dont know exactly where to start with the sound and how to send sound to the speakers. Can anyone help in this?
For games you should use DirectSound, so you can play more than one sound at the same time.
SilverShalkin wrote:
Well, thats all, "allot of questions like i said" but this is like a week of reading and toiling with out asking any at all " Some of the questions may be stupid and some maybe so lame or easy that maybe a quick syntax would help Sorry for the annoyance "to those who this annoys..."
Anyone who gets annoyed that you're trying to learn something is best ignored, not apologised to. The number of questions probably means I've given brief answers, but just ask if no-one here has yet clarified any of these points sufficiently.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
"I'm somewhat suspicious of STL though. My (test,experimental) program worked first time. Whats that all about??!?!
- Jon Hulatt, 22/3/2002
|
|
|
|
|
Thanks guys, the info that ive recieved is going to help allot Im off to program a little more and ask questions a little less "I dont know if that'll ever happend though "
~There is an end, when you cant learn any more... isnt there?
Thanks Again!
~SilverShalkin
ps... To those whom this annoys,...
I see thee no more
Christian Graus wrote:
Anyone who gets annoyed that you're trying to learn something is best ignored, not apologised to.
right when you think you have
learned it all, there is always
somthing that'll come allong just
to annoy you. I guess thats why
programming could be considered as the
unsolvable puzzle
where you recieve a peice of the picture
ever so often but still have thousands
of peices left.
|
|
|
|
|