|
I am using...
In the constructor:
m_nDefaultType = dynaset;
And to open:
rs.Open(CRecordset::forwardOnly,_T("SELECT COUNT(*) FROM mytable"),CRecordset::readOnly);
|
|
|
|
|
Actually, the anonymous guy is correct. You should use GetRecordCount(). And I believe the reason the other doesn't work is because I think the GetFieldValue gets a column value rather than a returned recordset value. So just do a plain open with a NULL query in order to get the whole recordset then do a GetRecordCount.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Seems like you just want the number of records in the database, so why don't you use the CRecordset::GetRecordCount() function.
|
|
|
|
|
Yes this is a solution, but too slowly because you need to check all the recordset to know the number of records.
MoveFirst();
DoWhile(IsBof()) {
MoveNext();
count++;
}
Is more eficient to do a SELECT COUNT(*) rather a DoWhile().
Tomás
|
|
|
|
|
No. You don't check it like this.
For example:
let's say you have a class CMyRecordset derived from CRecordset, and you use the default SQL, once you open the your RS class all you have to do is this..
CMyRecordset rs(db);
long lNumOfRecords;
rs.Open();
// if opens without any problem..
// this should give you the number of records you are looking for..
lNumOfRecords = rs.GetRecordCount();
|
|
|
|
|
Good day,
Does anyone know what exactly GetSuperWndProc() does? I keep getting this as an unresolved external in my embeddedVC program even though I never call it. If I override it it will compile fine but crashes on execution. I was wondering if anyone knows what its supposed to do so that I can implement it. Thanks.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Are you using any thirdparty libraries?
I don't think it a standard API function. I have never seen it before, and a search on all of MSDN don't get anything...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Sorry, my bad, its GetSuperWndProcAddr(). But no, I'm not using any third party libraries. In MSDN it says its obsolete and I don't need to override it but for some reason eVC keeps telling me its an unresolved external in all of my View classes and in my FrameWnd.
Bret Faller
Odyssey Computing, Inc.
|
|
|
|
|
Hmmm, strange...
Anyway, you can read a lot about errors with GetSuperWndProcAddr here
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Hi there,
I am trying to create a SQL Server DSN using SQLConfigDataSource. Everything
seems ok, except for I can't figure out how to set the password part, to Windows Authentication as opposed to SQL Server Authentication. It appears that the latter one is the default and everytime I run my code it gets set to SQL Server Authentication.
thanks
|
|
|
|
|
add
\0TRUSTED_CONNECTION
to your
SQLConfigDataSource attributes
|
|
|
|
|
I need to prevent my control's drawing while it is loading the page. I'm doing it this way:
In OnBeforeNavigate2():
LockWindowUpdate(); In OnDocumentComplete2():
UnlockWindowUpdate(); And in OnEraseBkgnd():
return true;
That works fine except the one moment: after the page was loaded - my desktop is redrawing. I don't understand why is it do this... It haven't web-style. The running ie doesn't redrawing it's page, but desktop is flickering.
How can I suppress it?
With the best regards, Vitaly.
|
|
|
|
|
I have a dialog box with many different controls and an ok button.
the ok button has focus when starting the dialog.
I have set focus to other controls in the init of the dialog.
the other controls get focus i can type in them but the ok button has focus also and if the enter key is pressed at anytime the dialog exists.
Is there a way that i can stop this from happening?
|
|
|
|
|
Trap the KeyDown message (in PreTranslateMessage method) and on VK_RETURN set the focus according to your need.
|
|
|
|
|
Just to clarify - OK doesn't keep the focus, but it is the default button (that's one of the button styles), so pressing ENTER triggers that button.
--Mike--
http://home.inreach.com/mdunn/
A recent survey reports that 1/4 of all internet users in England surf for porn.
The other 3/4 just didn't want to admit it.
|
|
|
|
|
Hi!
Does anyone know how to convert:
1. An integer to a string
2. A string to an integer
I know you can do this in Borland Delphi (IntToStr(), StrToInt()) so I wondered if it is possible to do the same in Visual C++...
Any help would be greatly appreciated...
James Bird - birdjames@bigfoot.com
|
|
|
|
|
itoa() int to string
atoi() string to int
both are part of stdlib.h
Cheers,
-Erik
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
My thoughts are my own and reflect on no other.
|
|
|
|
|
Integer to a string, use itoa, ltoa, or ultoa:
char str[4];
itoa(number, str, 10);
String to an integer, use atoi or atol:
int i=atoi("12");
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
Also, if you are using std::string (which by the way is a lot easier to deal with than char arrays), you can use std::stringstream for your conversions. The nice thing, too, is that if you know how to use cout, then you can use stringstream. It can handle ints, floats, whatever.
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
int main()
{
int i = 1;
float f = 2.0;
stringstream ss;
ss << "Let's print some numbers: " << i << "\t" << f;
string s = ss.str();
cout << s << endl;
return 0;
}
The output is:
Let's print some numbers: 1 2.0
|
|
|
|
|
Whoops, btw, the three #includes that got deleted were for string, iostream and sstream. Darn these HTML tags.
|
|
|
|
|
I am using the rich edit control to preview a report.
I have every just the way i want it execpt, i can not figure out how to draw a line(to separtate the header from the body)
Thank you anyone.
|
|
|
|
|
My guess would be to calculate where abouts on the rich edit control the line has to go, and then draw using its dc:
int x = 2; // X = X Position Of Line In The Richedit Control
int y = 20; // Y = Y Position Of Line In The Richedit Control
int xs = 200; // XS = Size Of The Line (Horizontal)
CRichEditCtrl m_richedit;
CDC pDC = m_richedit.GetDC();
pDC.MoveTo(x, y);
pDC.LineTo(xs, y);
...
Hope this helps,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
I implemented the following
my font height is 12
so an x of 20 should be between the two lines.
but the line does not show up.
any thought ?
thank you
CDC* pDC = m_richedit.GetDC();
m_richedit.SetSel(-1,-1);
m_richedit.ReplaceSel("Report Header\n\n");
pDC->MoveTo(20,20);
pDC->LineTo(20,100);
m_richedit.ReplaceSel("Report Data");
+++many more lines
|
|
|
|
|
Can't you just underline the text "Report Header"?
--
Alex Marbus
www.marbus.net
But then again, I could be wrong.
|
|
|
|
|
I could if I had to but it would not look that pleasing to the eye.
What i really need is a fomatted line divider.
I would like to also control the width of the line.
|
|
|
|