|
Hello all, using the ADO _ConnectionPtr->Exexute() method, i can add new rows to my Access 2000 database, the problem is like this, assume theres a table called people, with fields per_id of type Autonumeric, and name of type Text(50), if i write my sql to add a new record like this:
INSERT INTO people VALUES(NULL, 'mike')
then i get a com exception saying that i cannot assign Null to a non Variant type variable. If i write it like:
INSERT INTO people VALUES(0, 'mike')
it works (once), but the database actually sets per_id to 0, instead of asigning an anuto-incremented value. So the question is:
what should i pass to an INSERT INTO statement when one of the fields is autoincrement?
Thanks!
|
|
|
|
|
Ah! never mind guys, i just figured out:
INSERT INTO people (name) VALUES('mike')
Thanks NE way
|
|
|
|
|
I have been developing GUI applications for years in VB, but I am pretty new when it comes to VC++, so any help would be appreciated.
How do I create a MDI application that starts maximized and DOES NOT create a child window? I want to be able to create the window based on toolbar and menu commands not when the app starts.
Thanks!
|
|
|
|
|
write this code in ur app's Initinsatance function to prevent ur app from creating a child window during startup
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
//DON'T display a new MDI child window during startup!!!
cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
to start the window maximized
pMainframe->ShowWindow(m_nCmdShow); replace this by below line
pMainfram->ShowWindow(SW_SHOWMAXIMIZED);
Bye
Cool Ju
|
|
|
|
|
Thanks..That worked great!
|
|
|
|
|
In my SDI project in VC6.0, I want to derive a class from CArchive(), which will have two new methods:
WriteFormatString( ) and ReadFormatString( )
which basically follow the printf and scanf style.
so I have this included in MyDoc.h:
#include "MyArchive.h"
and in the same file, changed
virtual void Serialize(CArchive& ar);
to
virtual void Serialize(CMyArchive& ar);
In MyDoc.cpp,
I changed
void CMyDoc::Serialize(CArchive& ar)
to
void CMyDoc::Serialize(CMyArchive& ar)
But when I click on open or save menu items,
void CMyDoc::Serialize(CMyArchive& ar)
is not called.
What am I missing here?
Thank you very much for your help!
|
|
|
|
|
Hi,
When u change the serialize(CArchive& ar) to Serialize(CMyArchive& ar) it becomes a overloaded function and the compiler expects a definition for that function.
Write the function definition for Serialize(CMyArchive& ar) and override the Serialize(CArchive& ar) and call Serialize(CMyArchive& ar) from it.
Hope this solves ur problem.
Bye
Cool Ju
|
|
|
|
|
hi Cool Ju, Thank you for the direction, but I didn't quite follow.
How do I override Serialize(CArchive& ar)? I tried to replace
virtual void Serialize(CArchive& ar)
with
virtual void Serialize(CMyArchive& ar)
in myDoc.h, but it doesn't work.
Now what I do is in myDoc.h, add
virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
and in myDoc.cpp, implemented it as follows:
<br />
<br />
CFileException fe;<br />
CFile* pFile = NULL;<br />
pFile = GetFile(lpszPathName, CFile::modeCreate |<br />
CFile::modeReadWrite | CFile::shareExclusive, &fe);<br />
<br />
if (pFile == NULL)<br />
{<br />
ReportSaveLoadException(lpszPathName, &fe,<br />
TRUE, AFX_IDP_INVALID_FILENAME);<br />
return FALSE;<br />
}<br />
<br />
CMyArchivesaveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);<br />
saveArchive.m_pDocument = this;<br />
saveArchive.m_bForceFlat = FALSE;<br />
TRY<br />
{<br />
CWaitCursor wait;<br />
Serialize(saveArchive);
saveArchive.Close();<br />
ReleaseFile(pFile, FALSE);<br />
}<br />
CATCH_ALL(e)<br />
{<br />
ReleaseFile(pFile, TRUE);<br />
#if 0<br />
TRY<br />
{<br />
ReportSaveLoadException(lpszPathName, e,<br />
TRUE, AFX_IDP_FAILED_TO_SAVE_DOC);<br />
}<br />
END_TRY<br />
DELETE_EXCEPTION(e);<br />
#endif<br />
return FALSE;<br />
}<br />
END_CATCH_ALL<br />
<br />
SetModifiedFlag(FALSE);
<br />
return TRUE;
<br />
but I got a new problem here, I have to #if 0 some of the code out, cause the compiler complains that DELETE_EXCEPTION is not defined.
more hints please?
|
|
|
|
|
Hi lucy,
CDocument::OnSaveDocument(lpszPathName) internally calls serialize(CArchive savearchive)
Donot call serialize explicitly from CMyDoc::OnSaveDocument()
Instead try this
BOOL CMyDoc::OnSaveDocument(LPCTSTR lpszPathName)
{
BOOL bRetVal = CDocument::OnSaveDocument(lpszPathName);//this will internally call serialize()
}
Override serialize() by
void CMyDoc::Serialize(CArchive& ar)
{
CDocument::Serialize(ar); //first call parent's serialize
CMyArchivesaveArchive(pFile, CArchive::store | CArchive::bNoFlushOnDelete);
saveArchive.m_pDocument = this;
saveArchive.m_bForceFlat = FALSE;
CWaitCursor wait;
Serialize(saveArchive); // save me
saveArchive.Close();
ReleaseFile(pFile, FALSE);
}
void CMyDoc::Serialize(CMyArchive& saveArchive)
{
//write ur serialization code here
}
Bye
Cool Ju
Vote for Cool Ju
|
|
|
|
|
Thank you very much, Cool Ju, the coding is working now!
|
|
|
|
|
( maybe not the best wording for my question )
Let's say I have a vector :
std::vector< BaseObject* > myVector;
I can have an iterator like :
std::vector< BaseObject >::iterator it;
That will move on the vector.
now, if I have a class hierarchy with the BaseObject class as the class parent :
class Derive1 : public BaseObject {};
class Derive2 : public BaseObject {};
myVector.push_back( new Derive1 );
myVector.push_back( new Derive2 );
Is there a way with STL to iterate only on some type of object in the vector ?
For example, only iterator on the object of the type Derive1 instead of iterating over the whole list and manually each time check to see if it's of the right class ?
Or do I have to do a bigger wrapper over the vector ?
Thanks.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
The only way I can think of is using std::remove_if with a predicate function that does a dynamic cast. Not very pretty, IMO.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
IMHO the design is broken.
Relying on RTTI to query a heterogeneous collection either through a hand-rolled function or within the function object of the BOOST selective iterator mentioned is poor design.
This is C thinking within C++
I would suggest a rethink that does not sacrifice type safety.
Why do Derive1 & Derive2 have to be in the same collection?
They are not the same why try and treat them as if they are and then try and recast them?
|
|
|
|
|
#include <iostream>
#include <iomanip>
using namespace std;
bool Solve(int mat[][8], int x, int y);
void print(int mat[][8]);
void Initmat(int mat[][8]);
bool isvalid(int x, int y);
int counter=1;
int main() {
int mat[8][8];
Initmat(mat);
cout << "Generating solution...";
if (Solve(mat, 0, 0))
print(mat);
else cout << "No solution found" << endl;
return 0;
}
void Initmat(int mat[8][8]) {
for (int x = 0; x < 8; x++)
for (int y = 0; y < 8; y++)
mat[x][y] = 0;
}
void print(int mat[8][8]) {
cout << "Solution found!" << endl;
for (int x = 0;x < 8; x++) {
for (int y = 0; y < 8; y++)
cout << setw(4) << mat[x][y];
cout << endl;
}
}
bool Solve(int mat[8][8], int x, int y)
{
bool done=false;
if (counter == 65)
return true;
if (isvalid(x,y) && (mat[x][y] == 0))
{
mat[x][y] = counter; counter++;
if (!done)done=Solve(mat, x+2, y+1);
if (!done)done=Solve(mat, x+1, y+2);
if (!done)done=Solve(mat, x-1, y+2);
if (!done)done=Solve(mat, x-2, y+1);
if (!done)done=Solve(mat, x-2, y-1);
if (!done)done=Solve(mat, x-1, y-2);
if (!done)done=Solve(mat, x+1, y-2);
if (!done)done=Solve(mat, x+2, y-1);
if (!done){mat[x][y] = 0;counter--;}
}
return done;
}
bool isvalid(int x, int y) {
return ((x >= 0) && (x < 8) && (y >= 0) && (y < 8));
}
www.topsites.co.il
|
|
|
|
|
|
Howdy folks,
I'm having a little problem with FindFirstPrinterChangeNotification that has got me baffled. When I call this function on a laptop running XP Pro SP2 I get this error: This function is not supported on this system.
However this same .exe works fine on the other XP systems I've tested it on and calls the function with no problems.
If anyone has any insight into what could be causing this problem I would be very grateful for the help.
Thanks folks.
|
|
|
|
|
Flit wrote: When I call this function on a laptop running XP Pro SP2 I get this error: This function is not supported on this system.
So GetLastError() is returning ERROR_CALL_NOT_IMPLEMENTED ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Hi DavidCrow, thanks for the response.
FindFirstPrinterChangeNotification returns INVALID_HANDLE_VALUE .
GetLastError returns ERROR_CALL_NOT_IMPLEMENTED .
|
|
|
|
|
Are you using a different printer on the laptop? Is it possible that ultimately it's the printer driver that is saying "I don't support the notification that you've asked for"
|
|
|
|
|
Hi Graham, thanks for your help you set me on the right track.
I installed a new printer on the laptop and it worked fine, the printer I was testing with previously was a network printer.
I went to check on the network printer and it turned out that one of the helpful folk here had unplugged it because they needed the power outlet. I guess this happened between my succesful tests and when I started testing on the laptop.
I've added in some code to disregard any printers that aren't available and it's working fine.
Thankyou.
|
|
|
|
|
I'm writing an add-in for IE and i try to make a call to IWebBrowser::Navigate2 .
I provide an url string with a Google query, containing an already encoded japanese word to be searched. Unfortunately, the browser transforms the '%' characters into '%25', a sadness
Repeating the same procedure, with an IE control embedded into a dialog-based application, works just fine. So, i suppose it should be just a matter of browser control settings.
Do you know how could i get rid of this issue?
"dire io è lento, dire noi è rock"
rechi+
|
|
|
|
|
Bogdan Rechi wrote: I provide an url string with a Google query, containing an already encoded japanese word to be searched. Unfortunately, the browser transforms the '%' characters into '%25', a sadness
What about InternetCrackUrl and InternetCanonicalizeUrl api buddy
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
ThatsAlok wrote: InternetCrackUrl and InternetCanonicalizeUrl
Hi Alok, thanx for the reply.
I don't know about the InternetCrackUrl function. InternetCanonicalizeUrl is not working good for the UTF-8 stuff i needed. Anyway, i already encoded the URL by myself and i'm trying now to pass it to the browser. Normally, it should take it and execute it without any conversion but, unfortunately, it takes care about the '%' characters and everything explodes
I don't know how this is to be done but it has to be a way to do it. Google Toolbar itself is a succesful example.
"dire io è lento, dire noi è rock"
rechi+
|
|
|
|
|
Hi, I 'm trying to import a template class from dll A to another one, dll B, where I'm subclassing it and instantiating it. However I get the following linking error:
xmlCoreBuilder error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall MAGE::Builder<class mage::scene="">::Builder<class mage::scene="">(void)" (__imp_??0?$Builder@VScene@MAGE@@@MAGE@@QAE@XZ) referenced in function "public: __thiscall xmlCoreBuilder::SceneBuilder::SceneBuilder(void)" (??0SceneBuilder@xmlCoreBuilder@@QAE@XZ)
In the following error Builder is the base template class defined in dll A and SceneBuilder is a specialized sub-class of the former defined in dll B. I get the linking error when creating an instance of the sub-class in dll B:
xmlCoreBuilder::SceneBuilder* b = new xmlCoreBuilder::SceneBuilder;
I'm suspecting that I might have that problem because I export a template class, but I'm not sure. Can you think of anything?
Thank you,
Themis
|
|
|
|